For loop in Angular

Last Updated on

To move in an array of objects and work with each item in the iteration, use *ngFor and the let and of keywords:

    <ng-container *ngIf="arrCats">
    <span id="categoryBox" 
      *ngFor="let cat of arrCats;let indexOfelement=index;">
        {{indexOfelement}} -- {{cat.name}}
    </span>
    </ng-container>

Lämna ett svar