如何使用$ state.go toParams和$ stateParams发送和检索参数? [英] How to send and retrieve parameters using $state.go toParams and $stateParams?
本文介绍了如何使用$ state.go toParams和$ stateParams发送和检索参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将AngularJS v1.2.0-rc.2与ui-router v0.2.0一起使用.我想将引荐来源网址状态传递给另一个状态,因此我像这样使用$state.go
的toParams
:
I am using AngularJS v1.2.0-rc.2 with ui-router v0.2.0. I want to pass the referrer state to another state so I use the toParams
of $state.go
like so:
$state.go('toState', {referer: $state.current.name});
根据文档,在toState
控制器上填充$stateParams
,但它是undefined
.我想念什么?
According to the docs, this should populate the $stateParams
on the toState
controller, but it is undefined
. What am I missing?
我制作了一个小品来演示:
I've created a plunk to demonstrate:
推荐答案
我要做的就是像这样将参数添加到url状态定义中
All I had to do was add a parameter to the url state definition like so
url: '/toState?referer'
Do!
这篇关于如何使用$ state.go toParams和$ stateParams发送和检索参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文