ember-href-to icon indicating copy to clipboard operation
ember-href-to copied to clipboard

Respect parent route query params

Open Panman82 opened this issue 9 years ago • 6 comments

In my app I have a query param at the application level. Most of the time it'll never make it's way into the URL because the default value is not changed. However, when it is, it seems like any {{href-to}} URL's don't know about that, probably because it isn't passed in as (query-params). The issue would be that child routes don't really have direct access to the current value to pass in. Is there a way for this helper to know about those and add them to the URL automatically?

Panman82 avatar Oct 17 '16 14:10 Panman82

@cibernox Would PR #47 resolve this issue?

Panman82 avatar Oct 17 '16 16:10 Panman82

Yes, that was the idea, but I have to admit that I hit a dead end with that. The logic around query params was quite messy. I should try to finish it, but I don't think I'll have time in the next days.

cibernox avatar Oct 17 '16 17:10 cibernox

Any news on this ? I found this thread: https://stackoverflow.com/questions/37268480/how-can-i-get-url-params-in-emberjs-component

homersimpsons avatar May 26 '17 08:05 homersimpsons

@homersimpsons I didn't find a solution for the PR and i forgot about it. I'm not sure if with the new router service almost done in newer versions we should keep pursuing this as it will be an "official" href-to soon.

cibernox avatar May 26 '17 08:05 cibernox

@cibernox Okay, thank you for your answer :)

homersimpsons avatar May 26 '17 09:05 homersimpsons

It should be possible to achieve this via ember-router-helpers.

{{#with (route-params 'parent.child') as |routeParams|}}
   <a href={{routeParams.url}}
    class={{if routeParams.isActive "active" "inactive"}}
    {{action routeParams.transitionTo}}>Blah</a>
{{/with}}

I didn't test it directly, but I tried it in my own version of those. The core difference is that the transition is not handled via URL handling but by using route params directly.

MartinMalinda avatar Aug 19 '17 18:08 MartinMalinda