0

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

<!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

(function (angular) {
'use strict';

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

 })(angular);

app/module/module.route.js

(function () {
'use strict';

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

app/module/module.controller.js

(function (angular) {
'use strict';

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

ModuleController.$inject = [...];

1 Answer 1

3

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);

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);

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thks Raul. I forgot this damn [] after the module name !
you're welcome. This kind of things hapend very often

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.