Link-to helper to reset query param(s) to null?


I’ve ran into an issue with link-to helper and a route which has optional query params.

I have a ‘projects’ route which lists all Projects, but the related view also offers a list of links which filter the Projects out by their Category ('/projects?category=art'). So, default controller properties that link to query-params are all null. I’m having a hard time figuring out how to place a link-to helper in the same view which leads to a ‘clean’ route, without the query params. Placing a link-to helper with no query-params just leads to the current projects route, keeping any query params from the current URL - and what’s worse, keeps it marked as active.

Is there any way to force the link-to helper to ignore current URL query params?


For something similar, I added a controller property such as

defaultCategory: null

and then in the link-to helper used

(query-params category=defaultCategory)

I’d love for a simpler way to reset a query param though.


I’ve ran into a similar issue, I have a controller that supports quite a handful of query params and would like to have a link-to that reset all of the query parameters to their defaults.

Currently there doesn’t seem to be any way to do this without explicitly specifying each and every query param that you want to reset, and having a reference to what the default should be.

Am I missing something?


They are on to something:


Setting it to “null” (as a string) worked for me. Don’t remember how I landed on that one. Clearly not super intuitive.

        = link-to "admin.classes" (query-params filter="archived")
          span Archived
        = link-to "admin.classes" (query-params filter="null")
          span All