在rails上使用angularjs和ruby时出现未知的提供程序电子提供程序错误 [英] Unknown Provider e-provider error while using angularjs and ruby on rails

查看:82
本文介绍了在rails上使用angularjs和ruby时出现未知的提供程序电子提供程序错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Rails / AngularJS应用程序,可以在本地开发环境中正常运行。但是,当我将此应用程序部署到Amazon Cloud时,AngularJS会在浏览器控制台中返回此错误:

I have a Rails/AngularJS app which works fine in local development environment. However, when I deployed this app to Amazon Cloud the AngularJS returns this error in the browser console:

Unknown provider: eProvider <- e

但它在开发环境中运行良好。

However it works fine on development environment.

我从我的一个javascript文件中访问以下服务..例如: -

I am accesing the below service from one of my javascript files.. for eg:-

userList. storeActorListWithId()

我的服务如下: -

My service is the following:-

 woi.service('userList',['$rootScope', 'userAPI' , 'recoAPI', function($rootScope, userAPI, recoAPI){

    var actorList = [];
    var actorId = "";
    return{
        storeActorListWithId: function(data){
            actorList = [];
            angular.forEach(data,function(actor){
                if(actor.castname)
                {
                    actorList.push({name: actor.castname,id: actor.castid});
                }
            })
        } ,
        getActorListWithId: function(){
            return actorList;
        },
        storeActorId: function(id){
            actorId = id;
        },
        getActorId: function(){
            return actorId;
        }
    }

}]);

我的application.js文件如下。它是否安全缩小。

My application.js file is as follows.Is it minification safe or not.

 resolve: {
                checkActorId: function($route,$location,$rootScope){
                    var url = $route.current.params.id;
                    var actorName = url.replace(/\-/g, " ").replace(/\~/g, "-").replace(/\$/g, "/");
                    var  actorList = $rootScope.storeActorNameAndId;
                    if($rootScope.storeActorNameAndId){
                        angular.forEach(actorList, function(actor, key){
                            if(actor.name == actorName){
                                $rootScope.actorid = actor.id;
                            }
                        });
                    }
                    else
                    {
                        $location.path("home")
                    }
                }
            }

我在网站上尝试了很多解决方案(使用DI),但没有一个能帮助我。
请帮助我..

I have tried many solution(use of DI) given on the website but none of them is helping me. Please Help me..

提前致谢

推荐答案

经过数小时的研究后终于得到了解决方案。

Finally got the solution after hours of research.

解析块中存在 minification-safe 注释的问题。此代码给出了上述错误。

There was problem of minification-safe annotation in resolve block. This code was giving the above error.

resolve: {
    setParams: function($rootScope, $route) {
        $rootScope.Programmeid = $route.current.params.programmeid;
        $rootScope.channelid = $route.current.params.channelid;
    }
}

我通过将代码更改为:

resolve: {
    setParams: ['$rootScope', '$route', function($rootScope, $route) {
        $rootScope.Programmeid = $route.current.params.programmeid;
        $rootScope.channelid = $route.current.params.channelid;
    }];
}

这篇关于在rails上使用angularjs和ruby时出现未知的提供程序电子提供程序错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆