未添加错误:[$ injector:modulerr]添加其他依赖项时

时间:2015-07-30 02:39:30

标签: javascript angularjs

我正在使用州(ui.router)管理我的观点。但是,如下所示向模块添加其他依赖项会导致错误:

  

未捕捉错误:[$ injector:modulerr]

让我的状态破裂。

var MyApp = angular.module('MyApp', ['ui.router', 'ui.bootstrap']);

然后我将上面改为

var MyApp = angular.module('MyApp', ['ui.router', 'ui.bootstrap', 'angularGrid']);

支持角度网格。当我添加第3个依赖项时,angular会抛出错误。然后我改变了代码如下

var MyApp = angular.module('MyApp', ['ui.router', 'ui.bootstrap');
MyApp = angular.module('MyApp', ['angularGrid');

然而运气不大,仍然得到同样的错误。

我有什么遗失的吗?

错误:

Failed to instantiate module angularGrid due to:
Error: [$injector:nomod] http://errors.angularjs.org/1.4.3/$injector/nomod?p0=angu...
    at Error (native)
    at http://localhost:50196/Scripts/Angular/angular.min.js:6:416
    at http://localhost:50196/Scripts/Angular/angular.min.js:24:66
    at a (http://localhost:50196/Scripts/Angular/angular.min.js:23:109)
    at http://localhost:50196/Scripts/Angular/angular.min.js:23:352
    at http://localhost:50196/Scripts/Angular/angular.min.js:37:451
    at m (http://localhost:50196/Scripts/Angular/angular.min.js:7:322)
    at g (http://localhost:50196/Scripts/Angular/angular.min.js:37:229)
    at http://localhost:50196/Scripts/Angular/angular.min.js:37:398
    at m (http://localhost:50196/Scripts/Angular/angular.min.js:7:322

2 个答案:

答案 0 :(得分:0)

尝试为underscore.js包含依赖项

答案 1 :(得分:0)

根据错误,注射器无法找到模块angulgarGrid。你需要在index.html中加载angular-grid js。

var MyApp = angular.module('MyApp', ['ui.router', 'ui.bootstrap');
MyApp = angular.module('MyApp', ['angularGrid');

你应该为每个应用程序定义一次模块