在emberjs中的#each中访问索引 [英] Accessing Index in #each in emberjs
问题描述
大家好,请查看附上的代码
http:// jsbin .com / atuBaXE / 2 /
我试图使用{{@index}}访问索引,但似乎没有编译。我认为手柄支持
{{#模型中的每个项目}}
{{@index}}
{{item}}
{{/ each}}
我不知道{{@index}}是否得到支持
我正在使用
更新
由于这个PR ,现在可以使用带索引的每个帮助器,推进新的块参数语法。这是可用的金丝雀,希望将在默认情况下启用ember 1.11
{{每个模型为| item index |} }
< li>
索引:{{index}}内容:{{item}}
< / li>
{{/ each}}
对于旧版本
您可以使用 {{_ view.contentIndex}}
。
{{#每个项目在模型}}
< li>
索引:{{_view.contentIndex}}内容:{{item}}
< / li>
{{/ each}}
Hello everyone please check out the code attached
I am trying to access the index using {{@index}} but not seems to be compiling. I think handlebars supports that
{{#each item in model}}
{{@index}}
{{item}}
{{/each}}
It is not working out for, I can't figure out if the {{@index}} is supported or not
I am using
Ember.VERSION : 1.0.0 Handlebars.VERSION : 1.0.0
Thanks
UPDATE
Since this PR, it's now possible to use the each helper with index, taking advance of the new block params syntax. This is available on canary and hopefully will be enabled by default in ember 1.11
{{#each model as |item index|}}
<li>
Index: {{index}} Content: {{item}}
</li>
{{/each}}
FOR OLD VERSIONS
You can use {{_view.contentIndex}}
.
{{#each item in model}}
<li>
Index: {{_view.contentIndex}} Content: {{item}}
</li>
{{/each}}
这篇关于在emberjs中的#each中访问索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!