Failed to instantiate module error in Angular js

后端 未结 6 1090
我在风中等你
我在风中等你 2021-01-01 10:33

I encountered the following error with a root cause of Module \'ngRoute\' is not available

Uncaught Error: [$injector:modulerr] Faile

相关标签:
6条回答
  • 2021-01-01 11:12

    I got this error due to not pointing the script to the correct path. So make absolutely sure that you are pointing to the correct path in you html file.

    0 讨论(0)
  • 2021-01-01 11:14

    You need to include angular-route.js in your HTML:

    <script src="angular-route.js">
    

    http://docs.angularjs.org/api/ngRoute

    0 讨论(0)
  • 2021-01-01 11:18

    Such error happens when,

    1. You misspell module name which you injected.
    2. If you missed to include js file of that module.
    

    Sometimes people write js file name instead of the module name which we are injecting.

    In these cases what happens is angular tries to look for the module provided in the square bracket []. If it doesn't find the module, it throws error.

    0 讨论(0)
  • 2021-01-01 11:32

    For me the solution was fixing a syntax error:

    removing a unwanted semi colon in the angular.module function

    0 讨论(0)
  • 2021-01-01 11:33

    Or the minified version of the file...

    <script src="angular-route.min.js"></script>
    

    More information about this here:

    "This error occurs when a module fails to load due to some exception. The error message above should provide additional context."

    "In AngularJS 1.2.0 and later, ngRoute has been moved to its own module. If you are getting this error after upgrading to 1.2.x, be sure that you've installed ngRoute."

    Listed under section Error: $injector:modulerr Module Error in the Angularjs docs.

    0 讨论(0)
  • 2021-01-01 11:33

    For me the error occurred due to my browser using a cached version of the js file containing the module. Clearing the cache and reloading the page solved the problem.

    0 讨论(0)
提交回复
热议问题