简体   繁体   English

AngularJS 1.6 $ injector:modulerr错误

[英]AngularJS 1.6 $injector:modulerr Error

I've added some services to my application (which was working fine before-hand) and now it will not load and give me the error $injector:modulerr 我已经向我的应用程序中添加了一些服务(之前运行良好),现在它不会加载并给我错误$injector:modulerr

My app looks like this: 我的应用程序如下所示:

var app = angular.module("HtJobPortal", ["LocalStorageModule"]);
var serviceBase = "http://autherserverlink/";
var resourceBase = "http://resourceserverlink/";
(function () {
   "use strict";    
    app.constant("ngAuthSettings", {
        apiServiceBaseUri: serviceBase,
        apiResourceBaseUri: resourceBase,
        clientId: "TMS_Portal"
    });
    app.config(function ($httpProvider) {
        $httpProvider.interceptors.push("authInterceptorService");
    });
    app.run(["authService", function (authService) {
        authService.fillAuthData();
    }]);
})();

And the Services I have declared are: 我声明的服务是:

<!-- JS Scripts -->
<script src="//code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>

<!-- Application Directive -->
<script src="Scripts/controllers/app.js"></script>

<!-- Services -->
<script src="Scripts/services/authService.js"></script>
<script src="Scripts/services/authInterceptorService.js"></script>
<script src="Scripts/services/tokensManagerService.js"></script>

I've had a look around other similar errors and seen that this error can be caused by a number of things so I'm just not really sure how to narrow this down? 我查看了其他类似的错误,发现该错误可能是由多种原因引起的,所以我不确定如何缩小此范围? So I assumed the best place would be start with the declarations and the app itself? 所以我认为最好的地方应该是声明和应用程序本身?

You have forgotten to include the script containing the LocalStorageModule , which causes Angular to throw the $injector:modulerr . 您忘记了包含包含LocalStorageModule的脚本,这会导致Angular抛出$injector:modulerr

Simply include the missing scripts and that should solve your problem. 只需添加缺少的脚本即可解决您的问题。

请先在HTML中将应用程序加载LocalStorageModule的库或相关的js文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM