AngularJS模块'app.module'不可用 [英] AngularJS Module 'app.module' is not available

查看:81
本文介绍了AngularJS模块'app.module'不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是可加载依赖关系的FrontApp,但我遇到了以下错误:

I'm using a FrontApp that loads dependancies and I'm stuck with this error :

 Uncaught Error: [$injector:modulerr] Failed to instantiate module moduleApp due to:
 Error: [$injector:modulerr] Failed to instantiate module app.module due to:
 Error: [$injector:nomod] Module 'app.module' 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.

我可能在语法调用中遗漏了一些内容,但无法弄清楚:/

I probably miss something on my syntax call but can't figure out :/

index.html

index.html

<!DOCTYPE html>
<html ng-app="moduleApp">
.....

<script src="app/app.module.js"></script>
<script src="app/module/module.route.js"></script>
<script src="app/module/module.controller.js"></script>

app/app.module.js

app/app.module.js

(function (angular) {
'use strict';

var moduleApp = angular.module('moduleApp', [
    'app.module'
]);

 })(angular);

app/module/module.route.js

app/module/module.route.js

(function () {
'use strict';

angular
    .module('app.module')
    .run(appRun);
    .....

app/module/module.controller.js

app/module/module.controller.js

(function (angular) {
'use strict';

angular
     .module('app.module')
     .controller('ModuleController', ModuleController);

ModuleController.$inject = [...];

推荐答案

您永远不会创建 app.module 模块.在app/module/module.route.js

You never create app.module module. On app/module/module.route.js

(function () {
'use strict';

angular
    .module('app.module', [])
    .run(appRun);
    .....

此文件应在包含以下内容的文件之前加载:

And this file should be loaded before the file that contains:

(function (angular) {
'use strict';

    var moduleApp = angular.module('moduleApp', [
        'app.module'
    ]);

})(angular);

或仅添加您的app/app.module.js文件:

Or just add on your app/app.module.js file:

(function (angular) {
'use strict';
    angular.module('app.module', []); 
    var moduleApp = angular.module('moduleApp', [
        'app.module'
    ]);

     })(angular);

我建议您为模块选择有意义的名称,因为i9t具有 app.module appModule 模块,这很奇怪.

I recommend that you choose meaningful names for your modules, i9t is strange that you have app.module and appModule modules.

这篇关于AngularJS模块'app.module'不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆