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>{{item.name}}</li>

You can also try this approach

<ng-container *ngFor="let item of items" let-i="index">
  <li *ngIf="i<5">{{item.name}}</li>
</ng-container>
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments