I have itemlist which need to display with serial no. i used $index with ng-repeat but when element is hide at that time index was increased.
Code i tried as follow:
<div ng-repeat="itemRow in salesitem" class="tableRow h7" ng-hide="itemRow.flagDeleted">
<div class="tableCell">{{$index}}</div>
<div class="tableCell">{{itemRow.name}}</div>
<div class="tableCell">{{itemRow.qty}}</div>
</div>
when itemRow.flagDeleted is True at that item will not display but index will be increased so next item serial no is going wrong.
Instead use a filter on the repeat:
<div ng-repeat="itemRow in salesitem | filter:{ 'flagDeleted' : false}" class="tableRow h7">
<div class="tableCell">{{$index}}</div>
<div class="tableCell">{{itemRow.name}}</div>
<div class="tableCell">{{itemRow.qty}}</div>
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.