Angularjs ng-repeat索引

时间:2014-04-25 16:05:51

标签: angularjs

有没有办法可以获得ng-repeat当前记录索引?我试图给每个记录div一个id等于记录索引的例子:

 <div id="1"> 
 <div id="2"> 
 <div id="3"> 

任何一个例子都是高度贬值的。

我使用的ng-repeat如下:

      <div ng-repeat="rows in clients.Result">

2 个答案:

答案 0 :(得分:4)

$index包含当前索引。因此,您可以在ng-repeat {{$index}}内使用它。

所有这些变量都记录在ng-repeat documentation的最顶层。

答案 1 :(得分:4)

在评估卷发中使用$ index:

<div id="{{$index}}" ng-repeat="rows in clients.Result">

PLNKR