把手中的嵌套 'each' 块

Nested 'each' block in handlebars

有没有办法实现这样的事情:

{{#each firstArray as |first|}}
  {{#each secondArray as |second|}}
      // this should be value of object from second array with key from first array
    {{second[first]}}  
  {{/each}}
{{/each}}

可以嵌套每个块,您可以使用 this 引用父数组中的项目。最初的每个都使用它,因为我直接使用数组。如果它是 json 对象的一部分,我会改为引用密钥

https://jsfiddle.net/93fj7nje/

{{#each this}}
  <ul>
  {{#each this}}
    <li>{{this}}</li>
  {{/each}}
  </ul>
{{/each}}

lookup 助手允许您在 second 上查找 first

{{lookup second first}}

http://handlebarsjs.com/builtin_helpers.html#lookup

{{#each column in App.MyController.getColumnValues}}
      {{view App.CountView rowBinding="first" columnBinding="second"}}

请参考此页

Page

Page 2