我有一个带有“MapService”服务的“maps-services”模块,如下所示:
angular.module('maps-services', [])
.service('MapService', [$log, function($log) {
this.initMap = function() {
}
this.updateMap = function() {
}
}]);
I also have a 'maps' module depending on 'maps-services' as below:
angular.module('maps', [
'maps-services'
]);
当我依赖另一个模块中的“ map ”时,我收到一个未捕获的对象错误消息:
“[$injector:nomod] 模块 'ngLocale' 不可用!您拼错了模块名称或忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数。
http://errors.angularjs.org/1.3.0-beta.11/ $injector/nomod?p0=ngLocale"
我不明白发生了什么以及如何调试模块加载以更好地了解问题所在。
请你帮助我好吗 ?
问候。
最佳答案
80 年代编译器风格
这个异常消息让我想起了 80 年代编译器用来抛出的错误消息。
基本上当Angular抛出时:
Module 'ngLocale' is not available!
意思是说:
One of your modules wasn't loaded (but not ngLocale).
见 this和 this了解更多信息。
现在,为什么没有加载您的模块,或者它是什么模块,由您来解决。就我而言,有这个
angular.module( 'treeDemoApp' )
而不是这个angular.module( 'treeDemoApp', [] )
足以让 Angular 抛出这个消息。但是你的代码显然有 []
.Chrome 错误?
有一些建议( 1 , 2 )这是由于 chrome 中的错误。
关于AngularJS:由于服务和模块依赖而未捕获的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24227943/