【发布时间】:2014-01-03 08:31:57
【问题描述】:
从指令的角度来看,我有两个 ng-repeats。 该指令构建一个表格,每个表格单元格的数据来自另一个数据源。 这个数据源需要两个中继器的累积索引。
selectedKandidaat.AntwoordenLijst[$index].Value
我只有当前的 $index,或者 $parent.$index。因此,为了跟踪我想在 Antwoordenlijst[$index] 中使用的总体索引,我需要跟踪一个索引变量。我可以在视图中使用创建和更新索引变量吗?
类似这样的:
..
{{ totalIndex = 0 }}
<tr ng-repeat="opgave in opgaven">
<td ng-repeat="item in opgave.Items">
{{ totalIndex += 1 }}
..
实际代码
<table class="table">
<tr ng-repeat="opgave in opgaven">
<td ng-repeat="item in opgave.Items">
<select ng-model="selectedKandidaat.AntwoordenLijst[$index].Value"
ng-options="alternatief for alternatief in item.Alternatieven">
</select>
</td>
</tr>
</table>
【问题讨论】:
标签: javascript angularjs