DART Web UI:如何在迭代循环中引用索引

Pet*_*r B 3 dart dart-webui

我想在HTML中使用迭代循环的索引作为值,如:

   <select bind-value="gAddItem.drawType" 
            template iterate="int ind = 0; ind < gDrawDescs.length; ind++">
     <option value="{{ind.toString()}}"> {{gDrawDescs[ind]}} </option>
     </select>
Run Code Online (Sandbox Code Playgroud)

但是这种直观的语法似乎不起作用.有没有办法在Dart Web-ui中做到这一点?

Mat*_*rog 5

好消息,大家好!Seth Ladd与Peter B的回答有关的问题在几个月前得到修复,所以现在你可以{{$index}}从内部引用<template>.从该提交中添加的测试代码:

Test the $index meta variable:
<template repeat="item in items" indentation="remove">
  <div>
    "{{item}}" is the {{$index}}{{suffix($index)}} item out of {{$list.length}}.
  </div>
</template>
Run Code Online (Sandbox Code Playgroud)