ember 中的 {{#each as}} 语法是什么?

What is the {{#each as}} syntax in ember?

我在试图找出有关控制器的一些东西时遇到了这个问题 ,提问者在他们的 {{#each}}

中使用了这个语法
{#each content as |product index|}}
  {{index}}
{{/each}}

我以前从未见过这个,也找不到任何相关文档。有人可以解释一下这是做什么的吗?

这个语法是block params introduced in Ember 1.10。遵循此 link 将为您提供更多信息,但基本上它允许您对仍然具有内部可访问控制器(或组件)范围的集合进行迭代。

这里索引基本就是索引

{{somePropertyOnController}}
{#each content as |product index|}}
  <!-- index is an index in iteration -->
  {{index}}
  <!-- product is an object in the array / enumeration -->
  {{product}}
  <!-- still have access to controller -->
  {{somePropertyOnController}}
{{/each}}