Bird
0
0

What does the Angular directive *ngFor="let item of items" do in a template?

easy📝 Conceptual Q11 of 15
Angular - Directives
What does the Angular directive *ngFor="let item of items" do in a template?
AIt repeats the HTML element for each item in the list called 'items'.
BIt creates a single HTML element and ignores the list.
CIt deletes all items from the list.
DIt sorts the list before displaying.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the directive purpose

    The *ngFor directive is used to repeat an HTML element for each item in a list.
  2. Step 2: Analyze the syntax

    The syntax let item of items means for each element in the list 'items', create a copy of the element with 'item' as the current element.
  3. Final Answer:

    It repeats the HTML element for each item in the list called 'items'. -> Option A
  4. Quick Check:

    *ngFor repeats elements = A [OK]
Quick Trick: Remember *ngFor repeats elements for each list item [OK]
Common Mistakes:
  • Thinking *ngFor modifies the list itself
  • Confusing *ngFor with event binding
  • Assuming it creates only one element

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes