-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow passing null to query-params subexpression #10772
Comments
👍 I've had the same use case in my app. |
This needs to be requested upstream at https://github.com/wycats/handlebars.js/issues. |
The |
Yes. The Handlebars parser needs support for |
In the mean time you can probably (awkwardly) define subexpressions to do this.
{{#link-to 'foo' (query-params test=(null))}}...{{/link-to}} |
Thank you for that idea. That workaround is so, so much better than what we're doing now. Here's a JSBin with it in action. |
I'd also like to weigh in on this that in addition it would be great to be able to pass a simple The use case for this would be, for example if you had a filter bar with multiple different options (
Which is uhhhhh verbose. If we could assign What would be great is if you could instead say:
And have it know to simply remove all query params from the URL. |
@jfelchner I agree that that is verbose but simply unsetting every query param to null might have unintended consequences, especially when reaching for query params not owned by this controller. There is likely a compromise we can find. You should open a new issue to address this, as I'm about to close this one as fixed. |
|
It would be really great if you could pass
null
to the query params subexpression in alink-to
. Today, if I passnull
like this:I will end up on the route
localhost:4200/foo?test=undefined
because the subexpression is expectingnull
to be a variable it can access in my current context.A common use case of doing something like this is with clearing a search. Imagine I've implemented a search query parameter and I want to implement an "X" to clear the search. In order to use a link-to and clear the query parameter, I have to put a variable called
null
in context for the link-to to clear the query param from the address bar.Here's an example JSBin showing the issue I described.
The text was updated successfully, but these errors were encountered: