问题描述
我在中编写一个动作处理程序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 $的第一个参数c $ c>将是。
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中的查询参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!