johnpapa / ng-demos

variety of angular demos
MIT License
1.7k stars 961 forks source link

Uncaught Error: [$injector:nomod] Module 'app.layout' 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. #28

Closed arnorhaux closed 10 years ago

arnorhaux commented 10 years ago

Hi John

I noticed that you blogged about this error when injecting angular modules in your project:

http://www.johnpapa.net/easy-fix-to-a-common-angular-module-error/

Uncaught Error: [$injector:nomod] Module 'app.layout' 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.

What I did was adding '[]' to every line where angular module would be declared for example:

angular
    .module('app.layout',[])
    .controller('Shell', Shell);

And the error would disappear.

Do you think this is related to mixing versions of js files if I add them with nuget?

johnpapa commented 10 years ago

If you add the , [] then you are creating a new module there. I dont think you want to do that in every file.

Sometimes when you get that error, it means you are missing a file. Other times it means the module was defined after it was used. One way to solve this easily is to name the module files *.module.js and load those first.

DonnieLai commented 7 years ago

I have a similar problem. And I did as you told. But under Firefox is feasible, IE8 is still reported wrong