jeudi 31 octobre 2019

How to have dynamic values for queryParams in ember 2.17

I have a route where I want one of the params to be the first date of the previous month.

To do so I need to be able to dynamically set the start_date.

import Controller from '@ember/controller';

export default Controller.extend({
  queryParams: ['start_date'],
  start_date: "AAAAAA"
});

I tried to do it in the setupController :

setupController(controller, model) {
    this._super(controller, model);
    controller.set('start_date','BBBBBBBBB')
  }

But this is not correct :

1) it ignore a param passed via the URL. I want my dynamic value to act as a normal query param

2) The value of params in the model() is from the controller.

How can I have a synamic value (first day of last month) as the default value of a route's params ?




Aucun commentaire:

Enregistrer un commentaire