加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 16:57:59 所属栏目:安全 来源:网络整理
导读:我有一个’maps-services’模块和一个’MapService’服务,如下所示: angular.module('maps-services',[]).service('MapService',[$log,function($log) { this.initMap = function() { } this.updateMap = function() { }}]);I also have a 'maps' module de
我有一个’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).

有关详细信息,请参阅this和this.

现在为什么你的模块没有加载,或者它是什么模块,你可以解决.在我的情况下,有这个

angular.module( 'treeDemoApp' )

而不是这个

angular.module( 'treeDemoApp',[] )

足以让Angular抛出这个消息.但你的代码清楚地有[].

Chrome Bug?

有一些建议(1,2),这是由于chrome中的错误.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读