Ember doesn't show the query params in the url if the query params value is the default value. But I'd like to show it. Is there an option to change this behavior to show rather than hide?
App.IndexController = Ember.ArrayController.extend({
queryParams: ['type'],
type: "horror" // the default value, won't appear in URL or params
})
Default values and serialization is explained in this guide section. Unfortunately, it doesn't give a way to include the default value, and I'm not sure if there is a way out of the box.
However, there is a little trick. Instead of putting your default value in the controller, use null
and set the default value in your route when the query parameters are set up. This tricks Ember into thinking it's not the default value, when from your perspective it is.
App.IndexRoute = Ember.Route.extend({
resetController: function(controller) {
controller.set('type', 'horror');
return this._super.apply(this, arguments);
}
});
App.IndexController = Ember.ArrayController.extend({
queryParams: ['type'],
type: null
});