I'm using an ngfor to display a varying amount of items. I want to limit the amount of items it can display to 5 so I use:
<li *ngFor="let item of items; let i = index;">
<div *ngIf="i < 4">
//more stuff ...
</div>
</li>
But what this does it that it seems to be rendering the space for items over index = 4.
If I try:
<li *ngFor="let item of items; let i = index;" *ngIf="i < 4"> //Notice ngIF
Nothing is displayed.
Any ideas?
You can do it that way:
<li *ngFor="let item of items | slice:0:5; let i = index;">
<div>
//more stuff ...
</div>
</li>
Maybe that's an option that works for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With