微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – IE 11中的$injector:modulerr错误使用AngularJS

我开发了一个AngularJS应用程序,它适用于Firefox,Opera,Safari,Edge和Chrome,但它不适用于IE 11.

以下是我在IE 11中打开应用程序时遇到的特定错误消息:

[$injector:modulerr] Failed to instantiate module TicketSystemApp due
to: Error: [$injector:modulerr] Failed to instantiate module
TicketSystemControllers due to: Error: [$injector:nomod] Module
‘TicketSystemControllers’ is not available! You either misspelled the
module name or forgot to load it.

好像我的模块应用程序没有加载.

这是我的整个脚本加载:

  

<script>window.jQuery || document.write('<script src="../../assets/js/vendor/jquery.min.js"><\/script>')</script>
<!-- Angular js -->
<script src= "js/angular.min.js"></script>
<script src="https://code.angularjs.org/1.5.0/angular-route.js"></script>
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"></script>
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-aria.min.js"></script>
<!-- Angular Material Library -->
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.7/angular-material.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-messages.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src = "js/ui-bootstrap-tpls-1.2.1.js"></script>
<script src="bower_components/angular-bootstrap-lightBox/dist/angular-bootstrap-lightBox.js"></script>
<script src="js/angular-ui-router.js"></script>
<script src="js/md-data-table.min.js"></script>
<script src="js/toArrayFilter.js"></script>
<!-- auto-scroll module  -->
<script src="bower_components/angular-scroll-glue/src/scrollglue.js"></script>

<script src = "js/app.js"></script>
<!-- Controllers -->
<script src = "js/controllers.js"></script>
<script src ="js/globalFunctions.js"></script>
<!-- Custom File Upload Angular -->
<script src="js/ng-file-upload-shim.min.js"></script> <!-- for no html5 browsers support -->
<script src="js/ng-file-upload.min.js"></script>
<!-- FACTORY -->
<script src = "js/authInterceptor.js"></script>


<!-- Services -->
<script src="js/auth.js"></script>
<script src="js/session.js"></script>

<!-- loading bar -->
<script  src="bower_components/angular-loading-bar/build/loading-bar.min.js"></script>

我把它作为我的html标签

<html lang="en" ng-app="TicketSystemApp" xmlns:ng="http://angularjs.org" class="ng-app:TicketSystemApp" id="ng-app">

我的头标记确实如此:

<Meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

我尝试过手动引导但我只是得到两次相同的错误消息.

这是我的app.js(刚刚初始化):

var TicketSystemApp = angular.module('TicketSystemApp',[
    'ngRoute','TicketSystemControllers','angular-loading-bar','ngAnimate','ui.router','ui.bootstrap','ngMaterial','md.data.table','angular-toArrayFilter'
]);

这是我的controller.js(只是初始化).我用它来模块包含所有控制器:

var TicketSystemControllers = angular.module('TicketSystemControllers','ngMessages','ngFileUpload','bootstrapLightBox','luegg.directives'

    ]);

解决方法

Kenta,看起来你根本就没有创建控制器.你所做的是创建了两个模块,是你的意图吗?如果是这样,那么你需要重新调整脚本并确保清除缓存. IE 11有一个残酷的缓存问题.您的脚本应该以这种方式订购

<script src = "js/controllers.js"></script>
<script src = "js/app.js"></script>

我还注意到你有一个全局函数文件.如果你引用它的其他两个文件中有任何内容,那么该文件应该是第一个.我建议像这样设置你的脚本.

<script src= "js/angular.min.js"></script>
<script src="https://code.angularjs.org/1.5.0/angular-route.js"></script>
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-animate.js"></script>
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.7/angular-material.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-messages.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src = "js/ui-bootstrap-tpls-1.2.1.js"></script>
<script src="bower_components/angular-bootstrap-lightBox/dist/angular-bootstrap-lightBox.js"></script>
<script src="js/angular-ui-router.js"></script>
<script src="js/md-data-table.min.js"></script>
<script src="js/toArrayFilter.js"></script>
<script src="bower_components/angular-scroll-glue/src/scrollglue.js"></script>
<script src="js/ng-file-upload-shim.min.js"></script> <!-- for no html5 browsers support -->
<script src="js/ng-file-upload.min.js"></script>
<script  src="bower_components/angular-loading-bar/build/loading-bar.min.js"></script>


<script src = "js/controllers.js"></script>
<script src = "js/app.js"></script>
<script src ="js/globalFunctions.js"></script>
<script src="js/auth.js"></script>
<script src="js/session.js"></script>
<script src = "js/authInterceptor.js"></script>

我不知道这是否是确切的顺序,除非我看到你的所有JS,但我认为这非常接近.通常,您希望以正确顺序在您和所有供应商/第三方文件底部以正确顺序创建您创建的所有文件.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐