angular路由模拟微信页面切换和页面之间的传值
2016-07-21 21:30
495 查看
angular模拟微信页面的切换,页面之间传值。用路由。
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>路由的使用</title>
<script src="day2/src/angular.js"></script>
<script src="js/angular-route.js"></script>
<style type="text/css">
*{
padding: 0;
margin: 0;
}
body,html{width: 100%;height: 100%;}
.content{position: absolute; top: 0;left: 0;bottom: 49px; width: 100%;background: red;}
.footer{
display: flex;
position: absolute;left: 0; bottom: 0; height: 49px; width: 100%;border: 1px solid black
}
.footer a{ text-align: center;
text-decoration: none; flex: 1; border: 1px solid black;}
</style>
</head>
<body>
<div ng-app="fristApp">
<div class="content" ng-view></div>
<div class="footer" ng-controller="fristController">
<a href="#div1">微信</a>
<a href="#div2">通讯录</a>
<a href="#div3">发现</a>
<a href="#div4">我</a>
</div>
</div>
</body>
<script type="text/javascript">
var myApp = angular.module('fristApp',['ngRoute']);
myApp.config(['$routeProvider',function($routeProvider,$params){
$routeProvider
.when('/div1',{
// 使用$routeProvider配置路由,原理是当地址栏地址#之后的值跟when的值匹配,
//如果匹配成功就调用。
// template:"<p>p</p>"
template:"<p>div1</p>"
})
.when('/div2',{
templateUrl:"code22demo.html",
controller:'secondController'
})
.when('/div3',{
template:"<p>div3</p>"
})
.when('/div4/:name',{
template:"<p>div4</p>"
})
.when('/test/:param1',{
template:"<p>testHTML</p>",
controller:'thridController'
})
// 还可以直接加载进其他的页面,分离页面
.otherwise({
redirectTo:'/div3'
})
}])
myApp.controller('fristController',function(){
})
myApp.controller('secondController',function($scope,$location){
$scope.name = '';
$scope.clickNext = function(){
$location.path('test/'+$scope.name);
}
});
myApp.controller('thridController',function($scope,$routeParams){
console.log($routeParams);
console.log($routeParams.param1)
})
</script>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>路由的使用</title>
<script src="day2/src/angular.js"></script>
<script src="js/angular-route.js"></script>
<style type="text/css">
*{
padding: 0;
margin: 0;
}
body,html{width: 100%;height: 100%;}
.content{position: absolute; top: 0;left: 0;bottom: 49px; width: 100%;background: red;}
.footer{
display: flex;
position: absolute;left: 0; bottom: 0; height: 49px; width: 100%;border: 1px solid black
}
.footer a{ text-align: center;
text-decoration: none; flex: 1; border: 1px solid black;}
</style>
</head>
<body>
<div ng-app="fristApp">
<div class="content" ng-view></div>
<div class="footer" ng-controller="fristController">
<a href="#div1">微信</a>
<a href="#div2">通讯录</a>
<a href="#div3">发现</a>
<a href="#div4">我</a>
</div>
</div>
</body>
<script type="text/javascript">
var myApp = angular.module('fristApp',['ngRoute']);
myApp.config(['$routeProvider',function($routeProvider,$params){
$routeProvider
.when('/div1',{
// 使用$routeProvider配置路由,原理是当地址栏地址#之后的值跟when的值匹配,
//如果匹配成功就调用。
// template:"<p>p</p>"
template:"<p>div1</p>"
})
.when('/div2',{
templateUrl:"code22demo.html",
controller:'secondController'
})
.when('/div3',{
template:"<p>div3</p>"
})
.when('/div4/:name',{
template:"<p>div4</p>"
})
.when('/test/:param1',{
template:"<p>testHTML</p>",
controller:'thridController'
})
// 还可以直接加载进其他的页面,分离页面
.otherwise({
redirectTo:'/div3'
})
}])
myApp.controller('fristController',function(){
})
myApp.controller('secondController',function($scope,$location){
$scope.name = '';
$scope.clickNext = function(){
$location.path('test/'+$scope.name);
}
});
myApp.controller('thridController',function($scope,$routeParams){
console.log($routeParams);
console.log($routeParams.param1)
})
</script>
</html>
相关文章推荐
- TP QQ 微信 微博登录
- BadgeView微信消息数字提醒
- Java微信浏览器上传文件使用Base64方法(增加压缩上传方法)
- Android 接入微信支付
- iOS开发微信分享图片32K限制解决方案
- 编程小程序:1.编写程序,每次程序运行,产生5组双色球号码。每组号码升序排列,至少写出三种排序方法。
- 微信红包随机生成算法php版
- iOS中 最新微信支付/最全的微信支付教程详解
- 微信随机生成红包金额算法java版
- 微信公众号开发
- 通达OA 停用微信、钉钉企业号方法
- 微信登录
- android 仿微信多图选择器(带预览、照相功能)
- 类似支付宝或微信支付输入密码
- android版微信内置浏览器没有刷新,清缓存
- 微信js上传的图片只能保存3天 下载到自己的服务器
- 微信公众号掉粉的16种原因!
- 微信js-sdk config配置
- Android 跳转硬件公众号
- 微信js-sdk上传多个图片