I need to setup array of menu links in the router and then render them in template using #each. But seems like #linkTo helper didn\'t recognize variables. How can i solve th
This thread is not so recent and I do not know if most recent versions of Ember presents a different solution for this issue but on the Ember version 1.11 it works fine.
The solution is the inline version of link-to.
It works just like the helper (yes, it will toggle the active class for you depending on your current route) and allows you to pass dynamic parameters. Simulating the author's situation, we would have something like:
component.js
mainControls: [
{ path: 'widgets.new' },
{ name: 'Add' },
{ classes: 'btn btn-success icon-ok-sign' }
]
component.hbs
{{#each link in mainControls}}
{{link-to link.name link.route class=link.classes}}
{{/each}}
More details abut this approach can be found here.