如何更改Ember中的查询参数? [英] How do I change query parameters in Ember?

查看:70
本文介绍了如何更改Ember中的查询参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在中编写一个动作处理程序route:application

actions: {
  changeFoo(foo) {
    // I want to change the fooId queryParam to foo.get('id')
  }
}

问题是,我可以找到更改查询参数的唯一记录的方法是 transitionTo 'some.route',someModel,{queryParams:{...}} replaceWith 版本相同,但我在 route:application ,所以我不知道当前路由的名字,这意味着我不知道 transitionTo 将是。

The problem is that the only documented ways I can find to change the query params are transitionTo('some.route', someModel, { queryParams: { ... } } and the replaceWith version of the same. But I'm in route:application, so I don't know the current route's name. That means I don't know what the first argument to transitionTo would be.

有另一种方法来获取URL成为?fooId = 123

Is there another way to get the URL to become ?fooId=123?

推荐答案

你不需要当前的路由名称,你可以做'transitionTo({queryParams:{foo:123}) '路由器将其应用到正确的路由。

You don't need current route name. You can just do 'transitionTo({queryParams: { foo: 123 })'. The router will apply it to the correct route.

这篇关于如何更改Ember中的查询参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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