【问题标题】:Ember {{#linkTo}} helper's with {{each}}Ember {{#linkTo}} 助手与 {{each}}
【发布时间】:2014-02-04 09:36:12
【问题描述】:

我想从使用 {{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`

【问题讨论】:

    标签: ember.js-view


    【解决方案1】:

    你可能想看看这个。已经尝试过了,但嵌套的车把会很棒。

    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])
    })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-21
      • 2013-04-14
      • 2013-06-27
      • 2015-04-21
      • 1970-01-01
      • 2013-02-12
      • 1970-01-01
      相关资源
      最近更新 更多