AngularJS application config “Uncaught object” error (ngRoute)

后端 未结 4 1558
故里飘歌
故里飘歌 2020-12-11 04:26

I have this simple page:



    
        
        

        
相关标签:
4条回答
  • 2020-12-11 04:39

    RouteProvider is now in a separate module from the core Angular distribution. See https://docs.angularjs.org/api/ngRoute.

    Since it looks like you're using bower, I would do a

    bower install angular-route
    

    which will download the requisite .js file and place it in the bower_components directory. Modify the HTML to include this script. Then, the first line line in your application.js file should read:

    var betsApp = angular.module('betsApp', ['ngRoute']);
    
    0 讨论(0)
  • 2020-12-11 04:42

    In v1.2+, ngRoute is a separate module and should be loaded independently (and also declared as a dependency of your main module).

    <script src='bower_components/angular/angular.js'></script>
    <script src='bower_components/angular/angular-route.js'></script>
    
    var betsApp = angular.module('betsApp', ['ngRoute']);
    

    If you are using bower, you can download the ngRoute module with the following command:
    bower install angular-route

    0 讨论(0)
  • 2020-12-11 04:45

    You have to add angular-route module!

    0 讨论(0)
  • 2020-12-11 04:50

    Be sure your Module and ng-app are equals

    angular.module('foo', ['ngRoute']);
    
    <html ng-app="foo">
    
    0 讨论(0)
提交回复
热议问题