How to get the value of the index of *ngFor outside the loop?

时间:2016-10-20 19:15:01

标签: angular

here is my loop:

<div *ngFor='let item of items; let rowcount = index'></div>
<div>showing {{ rowcount }} of {{ items.length }}

But rowcount is showing NOTHING. Any suggestion on how I can get the value of rowcount correctly?

1 个答案:

答案 0 :(得分:3)

Maybe something like this, just need to display it after the last item.

<div *ngFor='let item of items; let rowcount = index'>
    <!-- Do all your stuff here -->

    <div *ngIf="last">showing {{ rowcount }} of {{ items.length }}</div>
</div>
相关问题