Which directive in Angular is used to add or remove an element from the DOM based on a condition?

  • *ngFor
  • *ngIf
  • *ngInclude
  • *ngSwitch
The *ngIf directive is used in Angular to conditionally add or remove an element from the DOM based on a given condition. If the condition evaluates to true, the element is rendered; otherwise, it is removed from the DOM. It's a fundamental directive for handling conditional rendering in Angular templates.
Add your answer
Loading...

Leave a comment

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