错误:[$ injector:modulerr]由于以下原因无法实例化myApp模块:[$ injector:nomod] Module' ui.bootstrap'不可用

时间:2015-07-08 17:52:49

标签: javascript angularjs twitter-bootstrap angular-ui

使用Firefox时出现以下错误:

SyntaxError: syntax error xml2json.js:1
SyntaxError: syntax error ui-bootstrap-tpls-0.13.0.js:1
Error: [$injector:modulerr] Failed to instantiate module myApp due to:
[$injector:modulerr] Failed to instantiate module ui.bootstrap due to:
[$injector:nomod] Module 'ui.bootstrap' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.3.14/$injector/nomod?p0=ui.bootstrap
minErr/<@http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js:63:5
module/<@http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js:1769:1
ensure@http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js:1691:5
module@http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js:1765:7
loadModules/<@http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js:4097:11
forEach@http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js:323:11
loadModules@http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js:4081:5
loadModules/<@h

以下是我的代码导入:

<head>
    <title>Automation Downloads</title>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-sanitize.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-cookies.js"></script>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="http://demos.amitavroy.com/learningci/assets/js/xml2json.js" charset="UTF-8"></script>
    <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.13.0.js"></script>
    <script src="default.js"></script>

    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="default.css">
</head>

这是我的JS文件:

var myApp = angular.module('myApp', ['ui.bootstrap', 'ngSanitize' , 'ngCookies']);

myApp.controller('myController', function($scope, $http, $modal, $log, $cookieStore){
    // all code goes here
});

有人可以帮帮我吗?我也有兴趣了解导致SyntaxError错误的原因。 Chrome中没有出现这些问题。我也尝试过SO上的所有解决方案,但没有一个能够解决问题。

由于

1 个答案:

答案 0 :(得分:0)

在头标记中添加ui.bootstrap.js文件,看看它是否正常工作

<head>
    <title>Automation Downloads</title>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-sanitize.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular-cookies.js"></script>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="http://demos.amitavroy.com/learningci/assets/js/xml2json.js" charset="UTF-8"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.13.0/ui-bootstrap‌​.min.js"></script>
    <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.13.0.js"></script>
    <script src="default.js"></script>

    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="default.css">
</head>