Ember:在Mixin中编程设置queryParams [英] Ember: Programatically set queryParams in Mixin

查看:147
本文介绍了Ember:在Mixin中编程设置queryParams的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



mixin有一个方法,当控制器保持mixin被初始化时,该方法被调用。

  setupQueryParams:(params) - > 
params.forEach(param)=>
@get('queryParams')。push(param)

在mixin我调用 @transitionToRoute({queryParams:{someParam:'something'}})没有任何反应。但是当我明确定义我的queryParams时,这样做是有效的。

解决方案

queryParams 被解析为类的原型,而不是一个实例,所以任何 init 功能将不会及时应用于ember来解决它。



这只是意味着 c $ c> queryParams 的后期绑定是不可能的。


I'm trying to programatically define queryParams in an Ember.Mixin.

The mixin has a method which is called when the controller holding the mixin is initialized.

setupQueryParams: (params) ->
  params.forEach (param) =>
    @get('queryParams').push(param)

Later in an action defined on the mixin I call @transitionToRoute({queryParams: {someParam: 'something'}}) nothing happens. However when I explicitly define my queryParams, this works.

解决方案

queryParams are resolved off the proto of the class, not an instance, so any init functionality wouldn't be applied in time for ember to resolve it.

This just means late binding of the queryParams isn't possible in the way you want.

这篇关于Ember:在Mixin中编程设置queryParams的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆