文章内容

2019/5/24 17:18:28,作 者: 黄兵

*ngFor index

在Angular中*ngFor如何计数呢?

具体代码如下:

<ul *ngFor="let item of items; index as i">
 <li>{{i+1}} {{item}}</li>
</ul>

可以在Angular 5/6/7中使用。


参考资料:ngFor with index as value in attribute


分享到:

发表评论

评论列表