mardi 5 avril 2016

Preserving active query params when transitioning to a nested route

I have an application that has customer profiles. The route is /customers/:id.

I also have a lot of nested routes, like /customers/:id/notes, /customers/:id/tasks and so on.

On the customer route, there is a query param called source that's set depending on which route the user transitioned from (and is used to show some context specific data).

That can be achieved like so:

{{#link-to "customer" customer.id (query-params source="someSource")}}

However, when I move to a sub route (like the notes route):

{{#link-to "customer.notes" customer.id}}

... the current active query params go back to default. I know this can be avoided if I pass in the currently active source to the notes route as well like this:

{{#link-to "customer.notes" customer.id (query-params source=source)}}

... but I have a lot of nested routes , so I want to know if there is a way to avoid passing in the currently active source query param everywhere and instead handle this on a higher level?




Aucun commentaire:

Enregistrer un commentaire