How to dynamically set params in link-to


#1

In my current code I am using link-to "routename " quaryparams–,but that routename is given manually .Can I get the route name dynamically in ember as I visited the different route pages.I am using ember 3.0 version


#2

Just use a controller attribute to define the route name.

{{#link-to pathVar }} link {{/link-to}}

//controller 
pathVar : 'index',

#3

The above code is not working . I used link-to in component . my code

//component

{{#dd.menu as |menu|}}
{{#menu.item}} {{#menu.link-to pathVar (query-params dateRange=“0”)}}This Week{{/menu.link-to}}
{{/menu.item}} {{/dd.menu}}

//controller

export default Controller.extend({

pathVar : ‘index’, queryParams: [‘dateRange’], dateRange: null,

filterByData: computed(‘dateRange’,‘model’, function(){

let dateRange = this.get('dateRange');    
let expenses = this.get('model'); 
 return expenses;
      }), 

});