我想遍历一个可枚举并显示一个计数器
<div template repeat="{{ name in names }}">
###. {{name}}
</div>
我应该用什么代替
###
所以它显示了名字的位置:1. John Doe
2. Jane Doe
3. etc...
最佳答案
Polymer 现在有能力做到这一点:
<template repeat="{{fruit in fruits | enumerate}}">
<li>You should try the {{fruit.value}}. It is number {{fruit.index}}.</li>
</template>
示例取自 https://github.com/sethladd/dart-polymer-dart-examples/blob/master/web/iterate_loop_index/my_example.html
关于dart - 在 dart 聚合物重复模板中获取索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19431835/