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.
Loading...
Related Quiz
- Your application has a module that is loaded lazily, and you want to ensure that this module is only loaded for administrators. How would you implement this restriction?
-
Consider a scenario where you have multiple
slots in a component. How can you ensure that specific content from a parent component is projected into the right slot? - A client asks you to highlight the currently active page link in the navigation menu. How would you achieve this in Angular?
- You're building a dashboard that fetches and displays data from multiple API endpoints simultaneously. To ensure that all data is loaded before rendering the dashboard, which RxJS technique would you employ?
- In an e-commerce application, you want to implement a feature to undo the last action (like adding an item to the cart). Which feature of NgRx would you leverage for this?