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.
Loading...
Related Quiz
- What allows you to dynamically load and render components in Angular?
- You have a requirement to build a complex multi-step form with the ability to navigate between steps and validate each step individually. What approach would you take in Angular to handle this?
- How can you configure the Angular CLI to generate components with inline templates and styles by default?
- The ControlValueAccessor interface provides a bridge between Angular's form controls and a native element in the DOM. This bridge includes methods like writeValue, registerOnChange, and ________.
- Which header is crucial for making a CORS request to a different domain using HttpClient?