arn-arn
arn-arn

Reputation: 1377

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

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?

Upvotes: 1

Views: 2694

Answers (1)

Logan H
Logan H

Reputation: 3423

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>

Upvotes: 3

Related Questions