[英]Ember.js is it possible to assign any value to transition object's data attribute?
When performing a transition from a route with transitionTo
method, I'd like to set it's data object some value? 使用
transitionTo
方法从路由执行transitionTo
,我想为其数据对象设置一些值吗? Is this possible somehow? 这有可能吗?
When entering the target route if I log transition
object in my model hook, I can see that transition object has an empty attribute like this: data: {}
. 输入目标路线时,如果我在模型挂钩中记录了
transition
对象,则可以看到过渡对象具有一个空属性,如下所示: data: {}
。
What is this object for if not to be used to transmit some data in it? 如果不用于在其中传输某些数据,此对象是什么?
Update 更新资料
Thanks to @Ben's answer I achieved my purpose in this way: 感谢@Ben的回答,我以这种方式实现了我的目的:
this.transitionTo('route.name').data = {my: 'data'}
I definitely use that regularly. 我肯定会定期使用。 Ember doesn't have it documented, although Ember's documentation doesn't really document the transition object as far as I recall.
尽管据我回忆,Ember的文档并没有真正记录过渡对象,但Ember没有记录它。 But it comes from
router.js
, and in router.js
it is documented as a public attribute for exactly the purpose you describe. 但是它来自
router.js
,在router.js
,出于您确切描述的目的,它被记录为公共属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.