如何使用 $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?
我创建了一个 plunk 来演示:
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'
呸!
这篇关于如何使用 $state.go toParams 和 $stateParams 发送和检索参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文