I was attempting to generate a list of links and found that some of them needed query params and others didn't. I could not find a recommended way to pass in a dynamic query-params object to the link-to helper. I ended up finding a solution in the Ember Discourse and decided to make it into an ember helper.
Helper:
import Ember from 'ember';
export function dynamicParams([routeName, params]/*, hash*/) {
return [
routeName,
{
isQueryParams: true,
values: params
}
];
}
export default Ember.Helper.helper(dynamicParams);
Usage:
{{link-to 'test-link' params=(dynamic-params routeName dynamicQueryParameters)}}
If you use the block version of link-to, you'll need to omit the route as the first param, and just use it in the dynamic-params: