我一直在解决我的heroku构建和一直无法确定为什么这个角模块没有实例化的原因。当我在本地主机上运行我的应用程序时,一切运行良好,所以我认为错误发生在Grunt的uglification过程中。所有类似的控制器模块似乎都可以正常加载,我可以在开发工具的“Sources”选项卡中看到它们。但是这个控制器文件没有显示出来,我假设它里面有一些错误。角度控制器模块无法实例化后Grunt uglify
这里是模块(控制器)不会实例:
angular.module('inspector.location', [])
.controller('LocationDisplayController', function($scope, $http, $routeParams,
ResultService) {
var controller = this;
this.inspections = ResultService.inspections;
});
样子变丑(我裂伤设置为false,试图解决这个问题)什么: angular.module(” (LocationDisplayController),函数($ scope,$ http,$ routeParams,Resu ltService){this.inspections = ResultService.inspections})
这是它唯一的非线性函数,内置依赖:
.service('ResultService', function(){
this.value = '';
this.inspections = '';
})
这里是app.js:
angular.module('inspector', [
'inspector.search',
'inspector.results',
'inspector.location',
'inspector.services',
'ngRoute'
])
,这里是完整的错误:
angular.js:4630 Uncaught Error: [$injector:modulerr] Failed to instantiate
module inspector due to:
Error: [$injector:modulerr] Failed to instantiate module inspector.location
due to:
Error: [$injector:nomod] Module 'inspector.location' is not available! You
either
misspelled the module name or forgot to load it. If registering a module
ensure
that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.5.6/$injector/nomod?p0=inspector.location
at https://ancient-sea-93514.herokuapp.com/scripts/angular/angular.js:68:12
. . . .
**编辑对所做的更改。
LocationDisplayController的新版本:
angular.module('inspector.location', [])
.controller('LocationDisplayController', ['ResultService',
function(ResultService) {
var controller = this;
controller.inspections = ResultService.inspections;
}]);
LocationDisplayController.$inject = ['ResultService']
或使用ng-annotate并让grunt添加依赖项注入数组 – charlietfl
模块在进行这些更改后仍然无法实例化(我独立尝试了它们,但将它们一并发布在此处)。然而,控制器的文件现在显示在Chrome开发工具的'Sources'选项卡中,但它包含我的index.html的html而不是控制器的javascript代码。我也拿出了控制器没有使用的依赖关系。 – swoopedj
不得不排除一个错字,显然当我在本地主机上运行应用程序时,Chrome并不在乎,甚至还没有处理依赖关系问题。谢谢!我使用$注射器选项。 – swoopedj