How can I limit *ngFor repeat to some number of items in Angular?

You can use the Slice Pipe for limit ngFor.

{{ value_expression | slice : start [ : end ] }}

<li *ngFor="let item of items | slice:0:5; let i=index>{{}}</li>

You can also try this approach

<ng-container *ngFor="let item of items" let-i="index">
  <li *ngIf="i<5">{{}}</li>

Leave a Reply

Your email address will not be published. Required fields are marked *