lundi 2 juillet 2018

How to set query param to null with an ember action?

In my Ember application I use query params to refresh model data and present new information. I have a use case that requires the ability to clear all the data and start with 'fresh' filters.

I'm attempting to create a 'reset' button in my ember application. This button should revert the existing query parameters in the URL to null.

The query parameters are configured on the route as follows:

export default Route.extend({
  queryParams: {
    dateFrom: {refreshModel:true},
    dateTo: {refreshModel:true},
    hours: {refreshModel:true}
  }
}),

I tried the following action on the route and controller seperately:

resetParams() {
      this.set('queryParams.hours', null)
    }

I have also tried simply this.set('hours', null) but it doesn't make a difference. The Ember documentation doesn't discuss clearing the params, just stopping them from being sticky.




Aucun commentaire:

Enregistrer un commentaire