Angularjs:缺少依赖性

时间:2016-03-18 07:52:39

标签: angularjs

当我启动angularjs应用程序时,我收到此错误

Uncaught Error: [$injector:nomod] Module 'App' 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.11/$injector/nomod?p0=App

因为我有大约20个依赖项。我如何知道哪个依赖项不满足?

angular.module('myApp', ['LocalStorageModule', 'tmh.dynamicLocale','ngResource', 'ui.router',   
'ngCookies','pascalprecht.translate', 'ngCacheBuster', 'ngTable',   
'ngSanitize','ui.select','angularValidator','ui.bootstrap','googlechart',   
'ui.bootstrap.showErrors','ngActivityIndicator','ncy-angular-breadcrumb',
'anguFixedHeaderTable', 'ui.utils','io.dennis.contextmenu'])

2 个答案:

答案 0 :(得分:4)

Angular正在尝试加载名为app的模块。如您的代码所示,您将模块名称定义为myApp - 因此只需将其中一个重命名为archieve name equality。

EG:

angular.module('app', ['LocalStorageModule', 'tmh.dynamicLocale','ngResource', 'ui.router',   
'ngCookies','pascalprecht.translate', 'ngCacheBuster', 'ngTable',   
'ngSanitize','ui.select','angularValidator','ui.bootstrap','googlechart',   
'ui.bootstrap.showErrors','ngActivityIndicator','ncy-angular-breadcrumb',
'anguFixedHeaderTable', 'ui.utils','io.dennis.contextmenu'])

答案 1 :(得分:1)

我不认为这是一个依赖问题,而只是一个命名问题。确保HTML中ng-app语句正确无误。根据它的外观,您的陈述可能是ng-app="App"而不是ng-app="myApp"