Angular 学习笔记——$rounte
<!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>
Angular 学习笔记——$rounte的更多相关文章
- angular 学习笔记
每天进步一点点,学习笔记 笔记来自 angular权威指南 如果想要屏蔽浏览器对表单的默认验证行为,可以在表单元素上添加 novalidate 标记. 而按钮标签则完全忽略 hr e f 属性,并不 ...
- angular学习笔记
1.forEach arr:参数是key,index json:与jquery相反,参数是value,key2.str-->json JSON.parse() ang ...
- angular学习笔记(3)
一.angular的核心 1.组件 2.指令 3.服务 4.依赖注入
- angular学习笔记(2)
1.angular可观察对象 2.angular绑定方式 3.angular模板 4.angular生命周期 5.angular组件通信
- Angular 学习笔记——$http
<!DOCTYPE HTML> <html ng-app="myApp"> <head> <meta http-equiv="C ...
- Log4j简单学习笔记
log4j结构图: 结构图展现出了log4j的主结构.logger:表示记录器,即数据来源:appender:输出源,即输出方式(如:控制台.文件...)layout:输出布局 Logger机滤器:常 ...
- angular学习资源
angular学习资源 angularjs库: https://developers.google.com/speed/libraries/devguide?hl=zh-CN#angularjs ...
- 小波说雨燕 第三季 构建 swift UI 之 UI组件集-视图集(六)Picker View视图 学习笔记
想对PickerView进行操作,只能在代码中操作. 下面 ,再添加三个label组件,然后将所有组件配置到代码中(看代码),然后要实现对PickerView的操作,就要实现它的DataSource协 ...
- DSP bootloader学习笔记1
DSP bootloader学习笔记1 彭会锋 参考: TMS320F28xx DSP中内部Flash的应用研究 http://wenku.baidu.com/view/83e9837931b765c ...
随机推荐
- #!/bin/sh简介
第一次学shell编程,看的文章中说shell程序必须以"#!/bin/sh"开始,也就认为是这样了,虽然知道在shell中以"#"开始的语句都是注释,但也从没 ...
- linux低权限执行高权限
1.关于sudo不需要输密码,低权限执行高权限,在root下的命令visudo放开%wheel ALL:保存退出, 执行gpasswd -a yourusername wheel 2.脚本命令下的,权 ...
- Html5学习进阶四 表单元素和表单属性
HTML5 的新的表单元素: HTML5 拥有若干涉及表单的元素和属性. 本章介绍以下新的表单元素: datalist keygen output 浏览器支持 Input type IE Firefo ...
- MFC does not support WINVER less than 0x0501 解决方案(转)
原文转自 http://blog.csdn.net/ygzhong000/article/details/41750841 解决方案:在stdafx.h头文件中添加以下行. #define WINVE ...
- C 实现删除非空文件夹
/* 文件名: rd.c ---------------------------------------------------- c中提供的对文件夹操作的函数,只能对空文件夹进行 删除,这使很多 ...
- SQL 数据库函数
字符串函数 lower(字符串表达式) | select lower('ABCDEF')返回 abcdef | 返回大写字符数据转换为小写的字符表达式. upper(字符串表达式) | select ...
- cordova学习:事件Events
deviceready: 当cordova完全加载,可以调用cordova API接口 支持平台:Amazon.Fire OS.Android.BlackBerry 10.iOS.Tizen.Wind ...
- hdu 5159(概率)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5159 题解:假设在 x 张牌中选b张牌,那么有 x^b 种选法,如果在 (x-1) 张牌中选 b 张 ...
- 本地虚拟机在ubuntu系统搭建nexus服务器
本地虚拟机在ubuntu系统上搭建nexus服务器 本地虚拟机在ubuntu系统上搭建nexus服务器所需软件: 虚拟机:VM或者Oracle VM VirtualBox 系统:ubuntu-14.0 ...
- Codeforces 839 B. Game of the Rows-贪心
最近太zz了,老是忘记带脑子... 补的以前的cf,发现脑子不好使... B. Game of the Rows time limit per test 1 second memory lim ...