Question 1:
For example I have opened the following route:
/marketplace/customers
Is there a possibility to make a transitionTo to the same route again but with other query params?
For example:
/marketplace/customers // empty search result list
/marketplace/customers?c=123&email=xxx@abc.de
/marketplace/customers?c=321&email=aaa@bbb.de
The problem is:
In first step I am in this route…
/marketplace
Here will be rendered a little component with a search form
After submit, I trigger a transitionTo with these query params like /marketplace/customers?c=123&email=xxx@abc.de.
Now the search component is still displayed.
If I submit a new search the same route like /marketplace/customers?c=321&email=aaa@bbb.de will be triggered but the model() method will not be called again.
Question 2:
It’s possible to change the url by transitionTo with query params?
Yes, just omit the route name and specify your query params. To control whether or not your model hook runs, use the queryParams options in the route object. The guides have a very good write up on this technique.
Thanks for this tip.
We have test it to call our same transition with other data but nothing happens.
When we debug into the deeps of ember we see that ember lost or remove our new or changed queryParams for the current transition.
In our target route ( same route ) we use the queryParams to call related REST requests.
But ember only jump into the model method at first time. If we submit our search with other params ember doesn’t jump into the model method again.
Here the code:
Ack. Typing on my phone and can’t format the code…
In the route, you need :
queryParams: {
cno: {
refreshModel: true
},
Email:{
refreshModel:true
},
model()…
In the controller, {
queryParams : [‘cno’,‘email’]
…
By the way, I have not attempted this from a component, only a controller or route. What I would recommend is to signal to the containing route that “something happened”, (itemClicked) and let the route determine what response to take (transition to). Doing so will make both more plug-n-play.