router配置中标明参数的名字. 以ui-router为例
$stateProvider.state(
'state1', {
url:
'/path/:id',
templateUrl:
'/path/to.html',
params: {
obj:
null
}
}).
使用$state进行页面切换
$state.go(
'state1', {
id:
'22',
obj: {
key:
'value'
}
});
在controller中使用$stateParams中获取参数
console.
log(
$stateParams.obj)
当然传递这种在url中没有体现的参数, 会在后退等操作时, 参数不可用.
https://segmentfault.com/q/1010000002784915
转载请注明原文地址: https://ju.6miu.com/read-1201139.html