I am using query-params to filter by category. I want the category to always be set. A missing category filter would ideally redirect to a url with a default category.
I have implemented this using query params, and a default value. However, I don’t like that the default query param is hidden, because the default value will change over time (manually, by redefining the default value).
/ defaults to filtering by a category
A. If a user decides to share this page which shows records of category
A, and I later redefine the default value of the category to be
B, the user who opens the shared link will not access the page that he would expect (showing records of category
The Ember guides include this statement about how the default value works for query-params:
When a controller’s query param property is currently set to its default value, this value won’t be serialized into the URL. So in the above example, if page is 1, the URL might look like /articles, but once someone sets the controller’s page value to 2, the URL will become /articles?page=2.
For this reason, I am wondering if there is a way to override this behavior. There might also be a better implementation for my use case that I am not aware of. Please, enlighten me.
Note that this question is very similar to ember.js - Is it possible to have Ember show a query parameter value in the url when the parameter is set to the default value? - Stack Overflow