我有以下ng-repeat
<div ng-repeat="product in ProductList" ng-show="ProductList.length >=1">
<h3> Product {{ProductList.length + 1}}</h3>
我需要做的就是在 h3
中显示序列号,例如
Product 1
Product 2
....
我该怎么做?
最佳答案
您可以使用$index
,参见doc
<div ng-repeat="product in ProductList">
<h3>Product {{$index + 1}}</h3>
</div>
您不需要 ngShow
因为 ngRepeat
不会迭代空数组
关于javascript - AngularJS ng-repeat 上的系列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33193543/