javascript 在 Rails 上使用 angularjs 和 ruby 时出现未知的提供商电子提供商错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20604469/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unknown Provider e-provider error while using angularjs and ruby on rails
提问by Catmandu
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:
我有一个 Rails/AngularJS 应用程序,它在本地开发环境中运行良好。但是,当我将此应用程序部署到 Amazon Cloud 时,AngularJS 在浏览器控制台中返回此错误:
Unknown provider: eProvider <- e
However it works fine on development environment.
但是它在开发环境中运行良好。
I am accesing the below service from one of my javascript files.. for eg:-
我正在从我的 javascript 文件之一访问以下服务.. 例如:-
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;
}
}
}]);
My application.js file is as follows.Is it minification safe or not.
我的 application.js 文件如下。缩小是否安全。
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")
}
}
}
I have tried many solution(use of DI) given on the website but none of them is helping me. Please Help me..
我尝试了网站上提供的许多解决方案(使用 DI),但没有一个对我有帮助。请帮我..
Thanks in advance
提前致谢
回答by Catmandu
Finally got the solution after hours of research.
经过几个小时的研究终于得到了解决方案。
There was problem of minification-safeannotation 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;
}
}
I resolved it by changing the code to this:
我通过将代码更改为以下来解决它:
resolve: {
setParams: ['$rootScope', '$route', function($rootScope, $route) {
$rootScope.Programmeid = $route.current.params.programmeid;
$rootScope.channelid = $route.current.params.channelid;
}];
}
回答by tnusraddinov
in my case
就我而言
app.config(function ($stateProvider) {
$stateProvider
.state('A', {
...,
});
});
was changed to
改为
app.config(["$stateProvider", function ($stateProvider) {
$stateProvider
.state('A', {
...,
});
}]);
then minification works
然后缩小工作
回答by Dorian
In my case (Rails app), I had to remove the uglifier
gem from my Gemfile
and then remove the config line in config/environments/production.rb
:
在我的情况下(Rails 应用程序),我必须uglifier
从我的中删除gem Gemfile
,然后删除配置行config/environments/production.rb
:
config.assets.js_compressor = :uglifier