AngularJs练习Demo16 ngRoute

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 5     <title></title>
 6     <meta charset="utf-8" />
 7     <script src="../Scripts/angular.min.js"></script>
 8     <script src="../Scripts/angular-route.min.js"></script>
 9 </head>
10 <body>
11     <div ng-app="myApp">
12         <div ng-controller="firstController">
13             {{text}}
14         </div>
15         <script type="text/javascript">
16             var app = angular.module("myApp", ['ngRoute']);
17             app.config(['$routeProvider', function ($routeProvider) {
18                 $routeProvider.when("/aaa/:num", {
19                     template: '<p>首页的内容</p>{{name}}', //templateUrl
20                     contorller:"Aaa"
21                 }).when("/bbb", {
22                     template: "<p>学员的内容</p>{{name}}",
23                     contorller:"Bbb"
24                 }).when("/ccc", {
25                     template: "test.html",
26                     contorller:"Ccc"
27                 }).otherwise({
28                      redirectTo:"/aaa"
29                 });
30             }]);
31         </script>
32 
33     </div>
34 </body>
35 </html>
原文地址:https://www.cnblogs.com/sumg/p/5605376.html