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