【问题标题】:Iterate over array in Ember Handlebars each遍历 Ember Handlebars 中的每个数组
【发布时间】:2014-05-08 10:30:12
【问题描述】:

我有一个对象,我已经在迭代它以使用把手 {{#each}} 在模板中显示内容 - 但是,在每个对象中都有一个数组,我还需要循环访问它。

需要实现类似的东西。

{{#each item}}

  {{title}}
  {{rating}}

  {{#each array_field}}
    {{field}}
    {{anotherField}}
  {{/each}}

{{/each}}

【问题讨论】:

    标签: javascript ember.js handlebars.js


    【解决方案1】:

    您可以创建指向当前项目的指针 var,然后查询您的数组属性:

    {{#each item in controller}}
      {{item.title}}
      {{item.rating}}
    
      {{#each otherItem in item.arrayField}}
        {{otherItem.field}}
      {{/each}}
    
    {{/each}}
    

    【讨论】:

      猜你喜欢
      • 2018-07-22
      • 2015-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-16
      • 2019-07-25
      • 1970-01-01
      • 2021-03-19
      相关资源
      最近更新 更多