<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="angular.min.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.2.9/angular-route.min.js"></script>
<script>
var m1 = angular.module('myApp',['ngRoute']);
m1.config(['$routeProvider',function ($routeProvider){
$routeProvider
.when('/aaa',{
template:'<p>aaaaaaaaaaaa</p>'
}).when('/bbb',{
template:'<p>bbbbbbbbbbb</p>'
}).when('/ccc',{
template:'<p>cccccccccccccc</p>'
})
}])
m1.controller('Aaa',['$scope',function ($scope){ }]) </script>
</head> <body>
<div ng-controller="Aaa">
<a href="#aaa">index</a>
<a href="#bbb">222222</a>
<a href="#ccc">33333</a>
<div ng-view></div>
</div>
</body>
</html>
<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="angular.min.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.2.9/angular-route.min.js"></script>
<script>
var m1 = angular.module('myApp',['ngRoute']);
m1.config(['$routeProvider',function ($routeProvider){
$routeProvider
.when('/aaa',{
template:'<p>aaaaaaaaaaaa</p>'
}).when('/bbb',{
template:'<p>bbbbbbbbbbb</p>'
}).when('/ccc',{
template:'<p>cccccccccccccc</p>'
})
}])
m1.controller('Aaa',['$scope','$location',function ($scope,$location){
$scope.$location = $location;
}]) </script>
</head> <body>
<div ng-controller="Aaa">
<a href="" ng-click="$location.path('aaa')">index</a>
<a href="" ng-click="$location.path('bbb')">222222</a>
<a href="" ng-click="$location.path('ccc')">33333</a>
<div ng-view></div>
</div>
</body>
</html>
<!DOCTYPE HTML>
<html ng-app="myApp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<script src="angular.min.js"></script>
<script src="http://cdn.bootcss.com/angular.js/1.2.9/angular-route.min.js"></script>
<script> var m1 = angular.module('myApp',['ngRoute']); m1.config(['$routeProvider',function($routeProvider){ $routeProvider
.when('/aaa/:num',{
template : '<p>首页的内容</p>{{name}}',
controller : 'Aaa'
})
.when('/bbb',{
template : '<p>学员的内容</p>{{name}}',
controller : 'Bbb'
})
.when('/ccc',{
template : '<p>课程的内容</p>{{name}}',
controller : 'Ccc'
})
.otherwise({
redirectTo : '/aaa'
}); }]); m1.run(['$rootScope',function($rootScope){ $rootScope.$on('$routeChangeStart',function(event,current,pre){
console.log(event);
console.log(current);
console.log(pre);
}); }]); m1.controller('Aaa',['$scope','$location','$routeParams',function($scope,$location,$routeParams){ $scope.name = 'hello';
$scope.$location = $location; console.log( $routeParams ); }]);
m1.controller('Bbb',['$scope',function($scope){ $scope.name = 'hi'; }]);
m1.controller('Ccc',['$scope',function($scope){ $scope.name = '你好'; }]); </script>
</head> <body>
<div ng-controller="Aaa">
<a href="" ng-click="$location.path('aaa/123')">首页</a>
<a href="" ng-click="$location.path('bbb')">学员</a>
<a href="" ng-click="$location.path('aaa/456')">课程</a>
<div ng-view></div>
</div>
</body>
</html>

最新文章

  1. poj2833
  2. CentOS添加163源
  3. Java 设计模式之代理模式
  4. [Maven]Maven 那点事儿
  5. Linq 中 表连接查询
  6. 深入理解 C# 协变和逆变
  7. Java中的访问权限
  8. 001.android初级篇之ToolBar
  9. 输入整数n(n&lt;=10000),表示接下来将会输入n个实数,将这n个实数存入数组a中。请定义一个数组拷贝函数将数组a中的n个数拷贝到数组b中。
  10. Lucene查询条数限制
  11. Spring boot +Spring Security + Thymeleaf 认证失败返回错误信息
  12. 你不知道的JS之作用域和闭包(二)词法作用域
  13. Web GIS离线地图
  14. 网络七层模型及TCP、UDP,一次HTTP请求都发生了什么
  15. BSGS&amp;扩展BSGS
  16. 事件对象event
  17. GreenDao3.2的简单使用
  18. spring学习 十六 spring加载属性文件
  19. idea本地将本地现有的项目和gitlab进行管理并提交到线上
  20. oracle数据库连接错误解决办法

热门文章

  1. dom内容区域的滚动overflow,scroll
  2. myeclipse maven web项目配置
  3. [ CodeVS冲杯之路 ] P1048
  4. 华为上机测试题(及格分数线-java)
  5. @Html.Raw()用法
  6. Bug预防体系
  7. POJ 2104 K-th Number (划分树)
  8. 加强版dd工具dc3dd
  9. CSS 标准发布流程
  10. Closest Binary Search Tree Value -- LeetCode