如何修正AngularJS 1.3.5模块加载错误?

时间:2017-02-18 10:50:22

标签: javascript angularjs

我有一个带有angularJS的简单html页面。这是我的html页面代码:

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

  });

我有一个app.js来配置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

当我在浏览器中加载我的html文件时,我有一个angularjs错误:

LocationMediaItem

我使用angularjs 1.3.5版本。请问哪里错了?

1 个答案:

答案 0 :(得分:1)

确保您的app.js正在加载,如果未加载,请尝试清除缓存

尝试保存所有字段并重新启动服务器。它应该工作。