0

我想从使用 {{each}} 帮助器迭代的项目列表中获取路线名称。如下面的示例。

<script type="text/x-handlebars" data-template-name="orders">
<h2> list all orders</h2> 
{{#each content}}
    {{#linkTo {{route name}} }}Some Text{{/linkTo}}
{{/each}}
</script>`enter code here`
4

1 回答 1

0

你可能想看看这个。已经尝试过,但这将是很棒的嵌套车把工作。

https://github.com/mateusmaso/handlebars.nested

如果上述方法不起作用,您可以尝试使用车把助手在控制器中设置变量。并使用 linkTo 上的变量值。这有点骇人听闻,但这就是我所做的:

/**
 * Used to set color of pie chart legend
 */
Ember.Handlebars.helper('setColor', function(controller, property, array, index) {
  controller.set(property, array[index])
})
于 2014-02-26T15:49:40.283 回答