samedi 8 avril 2017

Changing query param is not shown in the url

I want to click on a "export" button and transit to a route "home" with "export" query param set as true. I don't want this query param to refresh my route. So here is how my route looks like:

export default Route.extend(ApplicationRouteMixin, {
  queryParams: {
    export: {
      refreshModel: false
    }
  }
})

In my controller, i'm trying to observe the query param and call a function which does export for me and after that i want to set the query param back to null. here is my controller:

import Ember from 'ember'
const {Controller, inject} = Ember

export default Controller.extend({
  // == Dependencies ==========================================================
  session: inject.service(),
  // == Keyword Properties ====================================================
  queryParams: ['export'],
  export: null,

  queryParamsObserver: function () {
    if (this.get('export')) {
      this.exportFile()
      this.set('export', null)
    }
  }.observes('export'),

  // == Functions =============================================================
  exportFile () {
  },

  // == Actions ===============================================================
  actions: {
  }

})

But my problem is that when i set the query param to null, it won't change on the url. I'm wondering what i am missing here that is not causing that behavior. Plus that i wonder if using observing query param is the best solution to trigger some actions.




Aucun commentaire:

Enregistrer un commentaire