Which directive in Angular is used to loop over an array and render a list?

  • *ngClass
  • *ngFor
  • *ngIf
  • *ngSwitch
In Angular, the *ngFor directive is used to loop over an array and render a list. It iterates through the elements of an array or a collection and generates HTML elements for each item in the array. This is commonly used for rendering dynamic lists, such as a list of items retrieved from an API. *ngIf is used for conditional rendering, *ngSwitch is used for switching between multiple views, and *ngClass is used for dynamically adding or removing CSS classes.
Add your answer
Loading...

Leave a comment

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