I have a queryParam in my controller that is an array like so:
export default Ember.Controller.extend({
queryParams: ['customFilters'],
customFilters: []
// Other code goes here
}
Now I want to link to this controller and provide one or many values to the customFilters queryParam as an array like so:
{{#link-to 'search' (query-params customFilters=['selection1'])}}
Custom Selection
{{/link-to}}
Unfortunately the link-to helper doesn't seem to allow me to do that and just gives me a link to the search route with no query parameters. So I have two questions.
1) Is this something that I should be able to do?
2) Can I use the link-to helper to generate the link for me or should I try and hand roll it?
I'm going to assume that the route with the link-to has the ability to update the filters it wants to pass. In that routes controller:
export default Ember.Controller.extend({
arrayOfFilters: [
'Jon Snow',
'Tyrion Lannister',
'Stannis Baratheon'
],
SomeFunctionThatUpdatesTheArray() {}
});
In that routes template:
{{#link-to 'search' (query-params customFilters=arrayOfFilters)}}I have custom filters!{{/link-to}}
In the search route controller:
export default Ember.Controller.extend({
queryParams: ['customFilters'],
customFilters: []
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With