传值问题: $state.go(‘xxx’,{id:’1′}) 1.router配置中标明参数的名字. 以ui-router为例 $stateProvider.state(‘state1’, { ur
传值问题:
$state.go(‘xxx’,{id:’1′})
1.router配置中标明参数的名字. 以ui-router为例
$stateProvider.state(‘state1’, {
url: ‘/path/:id’, // 这个地方用简单字符串
templateUrl: ‘/path/to.html’,
params: {
obj: null // 这个地方就可以随便你用了. 因为这个参数没在state的url中体现出来
}
}).
2.使用$state进行页面切换
$state.go(‘state1′, {
id: ’22’,
obj: {
key: ‘value’
}
});
3.在controller中使用$stateParams中获取参数
console.log($stateParams.obj)
4.参数传递
console.log($state.current);
console.log($stateParams.merchantName);
——————————————————————————
.state(‘order-confirmation’, {
url: “/order-confirmation/{id}”,
templateUrl: “templates/product/order-confirmation.html”,
controller: ‘OrderConfirmation’
})
<a ui-sref=”order-confirmation({id:8})”> http://127.0.0.1:81/fw/#/order-confirmation/8
———————-
.state(‘order-confirmation’, {
url: “/order-confirmation”,
params:{‘id’: null, ‘mid’: null},
templateUrl: “templates/product/order-confirmation.html”,
controller: ‘OrderConfirmation’
})
$state.go(“order-confirmation”,{id:2,mid:33}); 、、 console.log($stateParams.mid); url后无信息
————————-
.state(‘order-confirmation’, {
url: “/order-confirmation/:id/:sid”,
a href=”#/order-confirmation/{{::8}}/{{::9}}”> http://127.0.0.1:81/fw/#/order-confirmation/8/9