Angular 控制器模块在 Grunt uglify 后无法实例化

Angular controller module fails to instantiate after Grunt uglify

我一直在对我的 heroku 构建进行故障排除,但无法确定此 angular 模块未实例化的原因。当我 运行 我的应用程序在本地主机上时一切 运行 都很好,所以我假设错误发生在 G运行t 的丑化过程中。我所有类似的控制器模块似乎都可以正常加载,我可以在开发工具的“源”选项卡中看到它们。但是这个控制器文件没有出现,我想是因为里面有一些错误。

这里是没有实例化的模块(控制器):

angular.module('inspector.location', [])
.controller('LocationDisplayController', function($scope, $http, $routeParams,
 ResultService) {
  var controller = this;
  this.inspections = ResultService.inspections;
});

丑化的内容(我将 mangle 设置为 false 以尝试解决此问题): angular.module("inspector.location", []).controller("LocationDisplayController",function($scope,$http,$routeParams,ResultService){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']

您需要使用数组语法指定依赖项,例如:

angular.module('inspector.location', [])
  .controller('LocationDisplayController', ['$scope', '$http', '$routeParams',
  'ResultService',
    function($scope, $http, $routeParams, ResultService) {
      var controller = this;
      this.inspections = ResultService.inspections;
    }
  ]);

或显式使用注入器,以便 angular 知道缩小后要注入什么。