【问题标题】:Get parent loop index each handlebars获取每个车把的父循环索引
【发布时间】:2014-09-25 08:11:58
【问题描述】:

这是我的导师

{{#each a in aa}}
     {{_view.contentIndex}} --> PARENT
  {{#each a in aa}}
      {{_view.contentIndex}} --> This should be the same PARENT val
   {{/each}}
{{/each}}

问题是我在第二个循环中获取当前范围的值,购买我需要获取父范围,有没有办法在 ember/handlebars 中获取这个?

【问题讨论】:

标签: javascript ember.js handlebars.js template-engine helper


【解决方案1】:

如果我对documentation 的理解正确,您应该可以这样做:

{{#each parent}}
    {{_view.contentIndex}} --> PARENT
  {{#with parent}}
    {{#each otherThing}}
       {{_view.contentIndex}} This should be the same PARENT val
    {{/each}}
  {{/with}}
{{/each}}

最外层的循环将是父项。

使用 {{with}} 的内部循环应该遍历每个父项中的每个项目。

【讨论】:

    猜你喜欢
    • 2019-02-07
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 2011-06-16
    • 1970-01-01
    • 1970-01-01
    • 2013-08-07
    • 1970-01-01
    相关资源
    最近更新 更多