AngulaJS路由 ui-router 传递多个参数
2016-08-13 11:30
246 查看
定义路由:
.state(‘txnresult’, {
url: ‘/txnresult/:originAmount/:finalAmount/:currentPoint/:txnId/:discountAmount’,
templateUrl: ‘templates/txnresult.html’,
controller: ‘TxnResultCtrl’
})
基本参数:
‘/user/:id’
‘/user/{id}’
‘/user/{id:int}’
使用正则表达式:
‘/user/{id:[0-9]{1,8}’
//匹配所有以user开始的url 并将剩余参数传给id
‘/user/{id:.*}’
‘/user/*id
传递参数方式1:
href=”#/txnresult/{{originAmount}}/{{finalAmount}}/{{currentPoint}}/{{txnId}}/{{discountAmount}}”
传递参数方式2:
$state.go(‘txnresult’,{originAmount: d.result.originAmount,finalAmount: d.result.finalAmount,currentPoint: d.result.currentPoint,txnId: d.result.txnId,discountAmount: d.result.discountAmount});
获取参数:
$scope.originAmount = $stateParams.originAmount;
$scope.finalAmount = $stateParams.finalAmount;
$scope.currentPoint = $stateParams.currentPoint;
$scope.discountAmount = $stateParams.discountAmount;
$scope.txnId = $stateParams.txnId;
.state(‘txnresult’, {
url: ‘/txnresult/:originAmount/:finalAmount/:currentPoint/:txnId/:discountAmount’,
templateUrl: ‘templates/txnresult.html’,
controller: ‘TxnResultCtrl’
})
基本参数:
‘/user/:id’
‘/user/{id}’
‘/user/{id:int}’
使用正则表达式:
‘/user/{id:[0-9]{1,8}’
//匹配所有以user开始的url 并将剩余参数传给id
‘/user/{id:.*}’
‘/user/*id
传递参数方式1:
href=”#/txnresult/{{originAmount}}/{{finalAmount}}/{{currentPoint}}/{{txnId}}/{{discountAmount}}”
传递参数方式2:
$state.go(‘txnresult’,{originAmount: d.result.originAmount,finalAmount: d.result.finalAmount,currentPoint: d.result.currentPoint,txnId: d.result.txnId,discountAmount: d.result.discountAmount});
获取参数:
$scope.originAmount = $stateParams.originAmount;
$scope.finalAmount = $stateParams.finalAmount;
$scope.currentPoint = $stateParams.currentPoint;
$scope.discountAmount = $stateParams.discountAmount;
$scope.txnId = $stateParams.txnId;
相关文章推荐
- ui-router传递参数
- AngularJS路由系列(4)-- UI-Router的$state服务、路由事件、获取路由参数
- ui-router传递参数
- ui-router传递参数
- ui-router带参数的路由配置
- ui-router 参数传递
- ionic 路由使用ui-sref 父页面向子页面传递参数
- 第5篇:ui-router路由带参数跳转后controller执行两次的问题处理
- angular ui.router 路由传参数
- ui-router传递参数
- angular4.0在路由Router时传递参数、获取参数的最灵活、阅读性最好的写法。
- UI-Router:为什么开发者都不喜欢Angular.js内置的路由
- 第4篇:ui-router 切换路由后页面不回到顶部的解决办法
- vue嵌套路由-query传递参数(三)
- 学习 ui-router - 路由控制
- vue嵌套路由--params传递参数
- AngularJS ui-router (嵌套路由)
- 详解Angular路由 ng-route和ui-router的区别
- 在 Angularjs 中 ui-sref 和 $state.go 如何传递参数
- AngularJS ui-router (嵌套路由)