2017-02-18 2 views
1

У меня есть простая html-страница с угловымJS. Вот мой HTML-код:Как исправить ошибку загрузки модуля AngularJS 1.3.5?

<!DOCTYPE html> 
<html ng-app="MyApp"> 
<head> 
    <base href="/"> 
    <meta charset="utf-8"> 
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>ShowTrackr</title> 
    <link rel="icon" type="image/png" href="favicon.png"/> 
    <link href="stylesheets/style.css" rel="stylesheet"> 
</head> 
<body> 
<!-- Nav Bar --> 
<div class="navbar navbar-default navbar-static-top" 
    role="navigation" bs-navbar> 
    <div class="navbar-header"> 
    <a class="navbar-brand" href="/"> 
     <span class="glyphicon glyphicon-film"></span> 
     Show<strong>Trackr</strong></a> 
    </div> 
    <ul class="nav navbar-nav"> 
    <li data-match-route="/$"><a href="/">Home</a></li> 
    <li data-match-route="/add"><a href="/add">Add</a></li> 
    </ul> 
    <ul class="nav navbar-nav pull-right" ng-if="!currentUser"> 
    <li data-match-route="/login"><a href="/login">Login</a></li> 
    <li data-match-route="/signup"><a href="/signup">Sign up</a></li> 
    </ul> 
    <ul class="nav navbar-nav pull-right" ng-if="currentUser"> 
    <li class="navbar-text" ng-bind="currentUser.email"></li> 
    <li><a href="javascript:void(0)" ng-click="logout()">Logout</a></li> 
    </ul> 
</div> 
<div ng-view></div> 

<script src="vendor/angular.js"></script> 
<script src="vendor/angular-strap.js"></script> 
<script src="vendor/angular-strap.tpl.js"></script> 
<script src="vendor/angular-messages.js"></script> 
<script src="vendor/angular-resource.js"></script> 
<script src="vendor/angular-route.js"></script> 
<script src="vendor/angular-cookies.js"></script> 
<script src="vendor/moment-with-locales.js"></script> 
<script src="app.js"></script> 
</body> 
</html> 

У меня есть app.js для настройки angularjs модуля и загрузить некоторый угловой модуль:

angular.module('MyApp', ['ngCookies', 'ngResource', 'ngMessages', 'ngRoute', 'mgcrea.ngStrap']) 
    .config(function() { 

    }); 

Когда я загрузить мой HTML-файл в браузере, у меня есть angularjs ошибка:

Uncaught Error: [$injector:modulerr] Failed to instantiate module MyApp due to: 
Error: [$injector:nomod] Module 'MyApp' 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.5/$injector/nomod?p0=MyApp 
    at http://localhost:3000/vendor/angular.js:63:12 
    at http://localhost:3000/vendor/angular.js:1747:17 
    at ensure (http://localhost:3000/vendor/angular.js:1671:38) 
    at module (http://localhost:3000/vendor/angular.js:1745:14) 
    at http://localhost:3000/vendor/angular.js:4050:22 
    at forEach (http://localhost:3000/vendor/angular.js:322:20) 
    at loadModules (http://localhost:3000/vendor/angular.js:4034:5) 
    at createInjector (http://localhost:3000/vendor/angular.js:3960:11) 
    at doBootstrap (http://localhost:3000/vendor/angular.js:1434:20) 
    at bootstrap (http://localhost:3000/vendor/angular.js:1455:12) 
http://errors.angularjs.org/1.3.5/$injector/modulerr?p0=MyApp&p1=Error%3A%2…otstrap%20(http%3A%2F%2Flocalhost%3A3000%2Fvendor%2Fangular.js%3A1455%3A12) 
    at http://localhost:3000/vendor/angular.js:63:12 
    at http://localhost:3000/vendor/angular.js:1747:17 
    at ensure (http://localhost:3000/vendor/angular.js:1671:38) 
    at module (http://localhost:3000/vendor/angular.js:1745:14) 
    at http://localhost:3000/vendor/angular.js:4050:22 
    at forEach (http://localhost:3000/vendor/angular.js:322:20) 
    at loadModules (http://localhost:3000/vendor/angular.js:4034:5) 
    at createInjector (http://localhost:3000/vendor/angular.js:3960:11) 
    at doBootstrap (http://localhost:3000/vendor/angular.js:1434:20) 
    at bootstrap (http://localhost:3000/vendor/angular.js:1455:12) 
http://errors.angularjs.org/1.3.5/$injector/modulerr?p0=MyApp&p1=Error%3A%2…otstrap%20(http%3A%2F%2Flocalhost%3A3000%2Fvendor%2Fangular.js%3A1455%3A12) 
    at http://localhost:3000/vendor/angular.js:63:12 
    at http://localhost:3000/vendor/angular.js:4073:15 
    at forEach (http://localhost:3000/vendor/angular.js:322:20) 
    at loadModules (http://localhost:3000/vendor/angular.js:4034:5) 
    at createInjector (http://localhost:3000/vendor/angular.js:3960:11) 
    at doBootstrap (http://localhost:3000/vendor/angular.js:1434:20) 
    at bootstrap (http://localhost:3000/vendor/angular.js:1455:12) 
    at angularInit (http://localhost:3000/vendor/angular.js:1349:5) 
    at http://localhost:3000/vendor/angular.js:25912:5 
    at HTMLDocument.trigger (http://localhost:3000/vendor/angular.js:2722:7) 
(anonymous) @ angular.js:63 
(anonymous) @ angular.js:4073 
forEach @ angular.js:322 
loadModules @ angular.js:4034 
createInjector @ angular.js:3960 
doBootstrap @ angular.js:1434 
bootstrap @ angular.js:1455 
angularInit @ angular.js:1349 
(anonymous) @ angular.js:25912 
trigger @ angular.js:2722 
eventHandler @ angular.js:2992 

Я использую угловую версию 1.3.5. Где я не прав, пожалуйста?

+0

все ссылки загружены правильно? – Sajeetharan

+0

Нет, мой app.js не загружен. Я не понимаю, потому что это тот же уровень, что и index.html. Другие библиотеки js загружаются правильно – Pracede

+0

да давайте посмотрим это в личном сообщении – Pracede

ответ

1

Убедитесь, что app.js загружается, если его не загружается, попробуйте очистить кэш,

Попробуйте сохранить все поля и перезапустить сервер. Он должен работать.

Смежные вопросы