我有一个’maps-services’模块和一个’MapService’服务,如下所示:
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' ]);
当我在另一个模块中依赖’maps’时,我收到一条未被捕获的对象错误消息:
“[$injector:nomod]模块’ngLocale’不可用!您拼错了模块名称或忘记加载它.如果注册模块,请确保将依赖项指定为第二个参数.
http://errors.angularjs.org/1.3.0-beta.11/ $喷油器/ NOMOD?P0 = ngLocale”
我不明白发生了什么以及如何调试模块加载以更好地了解问题所在.
请你帮助我好吗 ?
问候.
解决方法
80年代编译器的风格
此异常消息让我想起80年代编译器抛出的错误消息.
基本上当Angular抛出时:
Module ‘ngLocale’ is not available!
这意味着:
One of your modules wasn’t loaded (but not ngLocale).
现在为什么你的模块没有加载,或者它是什么模块,你可以解决.在我的情况下,有这个
angular.module( 'treeDemoApp' )
而不是这个
angular.module( 'treeDemoApp',[] )
足以让Angular抛出这个消息.但你的代码清楚地有[].
Chrome Bug?