案例:AngularJS案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
4
<script src="/js/angular.js1.4.6/angular.min.js"></script>
5
<script src="/js/angular.js1.4.6/angular-route.js"></script>
6
7
<script type="text/javascript">
8
angular.module('ngRouteExample', ['ngRoute'])
9
.controller('HomeController', function ($scope, $route) { $scope.$route = $route;})
10
.controller('AboutController', function ($scope, $route) { $scope.$route = $route;})
11
.config(function ($routeProvider) {
12
    $routeProvider.
13
    when('/home', {
14
        templateUrl: 'embedded.home.html',
15
        controller: 'HomeController'
16
    }).
17
    when('/about', {
18
        templateUrl: 'embedded.about.html',
19
        controller: 'AboutController'
20
    }).
21
    otherwise({
22
        redirectTo: '/home'
23
    });
24
});
25
</script>
26
27
  
28
</head>
29
30
<body ng-app="ngRouteExample" class="ng-scope">
31
  <script type="text/ng-template" id="embedded.home.html">
32
      <h1> Home </h1>
33
  </script>
34
35
  <script type="text/ng-template" id="embedded.about.html">
36
      <h1> About </h1>
37
  </script>
38
39
  <div> 
40
    <div id="navigation">  
41
      <a href="#/home">Home</a>
42
      <a href="#/about">About</a>
43
    </div>
44
      
45
    <div ng-view="">
46
    </div>
47
  </div>
48
</body>