javascript - Angular ng-Route doesn't work in a very simple example -


i learning angular.js , found example on w3c.school http://www.w3schools.com/angular/tryit.asp?filename=try_ng_routing

but when try test it doesn't work, made 2 .htm files containing 1 word, example "red", or "green". simple example cannot work. think might libraries using

<!doctype html>  <html>  <!-- javascript files -->  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular-route.js"></script>    <body ng-app="myapp">    <p><a href="#/">main</a>    </p>    <a href="#red">red</a>    <a href="#green">green</a>    <a href="#blue">blue</a>    <div ng-view></div>    <script>      var app = angular.module("myapp", ["ngroute"]);      app.config(function($routeprovider) {        $routeprovider.when("/", {          templateurl: "test.html"        }).when("/red", {          templateurl: "red.htm"        }).when("/green", {          templateurl: "green.htm"        });      });    </script>  </body>    </html>

in case moving towards page "red.htm" which,... doesn't exist in situation! page there in directory w3school (http://www.w3schools.com/angular/red.htm exmaple)

so need create htm page called red.htm in same directory , navigate using routing. if want make same example copy code of page linked , try run both files on same directory.


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -