use*_*679 5 javascript angularjs angularjs-ng-repeat
我想使用angularJS获取此表中每行的索引
<table>
<tbody>
<tr ng-repeat = "cust in costomers">
<td> cust.name </td>
<td> cust.phone </td>
<td> cust.address </td>
</tr>
</tbody>
Run Code Online (Sandbox Code Playgroud)
我想要一个包含每行索引的变量,而不是只显示它
小智 10
你可以使用$ index
<tr ng-repeat = "cust in costomers">
<td> {{$index}} </td>
</tr>
Run Code Online (Sandbox Code Playgroud)
我认为你应该使用<tr>标签来放置你的ng-repeat指令。您可以使用ng-repeat's $index财产。请参阅ng-repeat的文档。
<table>
<tbody>
<tr ng-repeat = "cust in costomers">
<td> {{$index}} </td>
<td> {{cust.name}} </td>
<td> {{cust.phone}} </td>
<td> {{cust.address}} </td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20958 次 |
| 最近记录: |