AngularJS:由于服务和模块依赖而未捕获的对象

标签 angularjs dependency-injection angularjs-module

我有一个带有“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).


thisthis了解更多信息。
现在,为什么没有加载您的模块,或者它是什么模块,由您来解决。就我而言,有这个
angular.module( 'treeDemoApp' )
而不是这个
angular.module( 'treeDemoApp', [] )
足以让 Angular 抛出这个消息。但是你的代码显然有 [] .
Chrome 错误?
有一些建议( 12 )这是由于 chrome 中的错误。

关于AngularJS:由于服务和模块依赖而未捕获的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24227943/

相关文章:

javascript - AngularJS 的多个部分 View

javascript - AngularJS ui-mask 添加货币的最大值和最小值

php - $stateChangeStart 在从 Rest API 获取数据之前运行

c# - Unity Bootstrapper (Unity.Mvc), Unity 3, MVC 5, EF6 接收错误 : Parameterless Public Constructor on Controller

c# - 如何为 Ninject 创建最小起订量供应商?

.net - 是否应该注入(inject)自定义配置部分依赖项?

angularjs - 双向绑定(bind)更新了哪些部分?

Javascript 日期字符串到 Angular ng-moment 变量

javascript - AngularJS 如何添加多个依赖模块

javascript - 为什么我使用 1.5 beta 得到 Angular $injector :modulerr error here?