一个列表循环,序号标识是常见的,c#语言如何实现,我们知道,C# repeater控件里添加序号的4种方法。那么在js框架angularjs里使用ng-repeat怎么实现添加序号呢?
直接上代码,一看就懂了:
<table class="table table-bordered mt20 table-td-center">
<thead>
<tr>
<th>序号</th>
<th>昵称</th>
<th>性别</th>
<th>年龄</th>
<th>星座</th>
<th>关注时间</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="fans in vm.data.users">
<td ng-bind="$index+1">1</td>
<td ng-bind="fans.nickname">郑州网建</td>
<td ng-bind="fans.gender=='m'?'男':'女'">男</td>
<td ng-bind="vm.getDate(fans.birthday)">32</td>
<td>白羊座</td>
<td>2014-09-02 00:00 </td>
</tr>
</tbody>
</table>
$index是从0开始计数的,所以,这里,我们+1