【发布时间】:2015-06-18 01:43:39
【问题描述】:
使用 Rails 4 和 AngularJS 迁移到生产服务器后,我遇到了错误:[$injector:modulerr] Failed to instantiate module EcoApp due to:
Error: [$injector:unpr] Unknown provider: e。
在阅读了其他 stackoverflow 问题和 angular 文档后,我认为错误是由于缩小而出现的。不幸的是,我对 Angular 的了解不够好,经过多次尝试修复我的代码后,我决定在这里寻求帮助。
我的控制器文件(在 CoffeeScript 中):
angular.module('EcoApp')
.controller 'MyTripsCtrl', ($scope, $http) ->
$http.get('/mytrips.json').success((data, status, headers, config) ->
$scope.mytrips = data
return
).error (data, status, headers, config) ->
# log error
return
return
.controller 'NavbarIsActive', ($scope, $location) ->
$scope.isActive = (select_path) ->
select_path == $location.path()
return
.controller 'NavbarIsActive2', [
'$scope'
'$location'
($scope, $location) ->
$scope.isActive = (select_path) ->
select_path == $location.path()
return
]
如您所见,我尝试修复控制器 NavbarIsActive,在我看来这是造成问题的原因,但没有任何结果。任何帮助将不胜感激!
【问题讨论】:
-
是在缩小你的代码吗?在您包含的任何控制器中,我都没有看到对
e的引用。实际上,如果您要缩小代码,则需要使用显式依赖格式,而不是让 Angular 通过名称推断您的依赖。 -
我想 Rails 在将服务器从开发更改为生产后正在缩小我的代码。
标签: javascript angularjs ruby-on-rails-4 coffeescript