Module is not available, misspelled or forgot to load (but I didn't)

后端 未结 9 2114
伪装坚强ぢ
伪装坚强ぢ 2020-12-13 12:17

I am fairly new to angular and using it with JSON api files. TO test, I am trying to use the free github api (my names for functions are for a different json api that i will

相关标签:
9条回答
  • 2020-12-13 12:35

    make sure that you insert your module and controller in your index.html first. then use this code in your module var app = angular.module("MesaViewer", []);

    0 讨论(0)
  • 2020-12-13 12:38

    You are improperly declaring your main module, it requires a second dependencies array argument when creating a module, otherwise it is a reference to an existing module

    Change:

    var app = angular.module("MesaViewer");
    

    To:

    var app = angular.module("MesaViewer",[]);
    

    Working Version

    0 讨论(0)
  • 2020-12-13 12:40

    It should be

    var app = angular.module("MesaViewer", []);
    

    This is the syntax you need to define a module and you need the array to show it has no dependencies.

    You use the

    angular.module("MesaViewer");
    

    syntax when you are referencing a module you've already defined.

    0 讨论(0)
  • 2020-12-13 12:43

    I had the same error but i resolved it, it was a syntax error in the AngularJS provider

    0 讨论(0)
  • 2020-12-13 12:47

    I found this question when I got the same error for a different reason.

    My issue was that my Gulp hadn't picked up on the fact that I had declared a new module and I needed to manually re-run Gulp.

    0 讨论(0)
  • 2020-12-13 12:49

    Using AngularJS 1.6.9+

    There is one more incident, it also happen when you declare variable name different of module name.

    var indexPageApp = angular.module('indexApp', []);
    

    to get rid of this error,

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

    change the module name similar to var declared name or vice versa -

    var indexPageApp = angular.module('indexPageApp', []);
    
    0 讨论(0)
提交回复
热议问题