AngularJS ng-view not working

后端 未结 3 809
渐次进展
渐次进展 2021-01-12 22:24

So I followed this guide: http://viralpatel.net/blogs/angularjs-routing-and-views-tutorial-with-example/

But when I try to change the view nothing happens, anybody a

相关标签:
3条回答
  • 2021-01-12 22:53

    Adding this would work :

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-route.js"></script>
    

    but it will not work without internet access when running for a first time ,Therefore you should ng-route dependency to your project and refer that in your html file

    How to add ng-route dependency

    0 讨论(0)
  • 2021-01-12 23:06

    From angular 1.2.0, ngRoute has been moved to its own module. You have to load it separately and declare the dependency.

    Update your html:

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-route.js"></script>
    

    And Js:

    var lax = angular.module('lax', ['ngRoute']);
    

    For more information: http://docs.angularjs.org/guide/migration

    0 讨论(0)
  • 2021-01-12 23:10

    Angular routes require the route module to be included as well. Here is the documentation that covers this.

    So, I think you may be missing the:

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

    In the <head> of the page.

    *Note: this module used to be part of Angular, but was moved out recently (1.2?). So, some tutorials are still assuming that $route is built-in.

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