Bird
0
0

Consider this Angular template:

medium📝 component behavior Q5 of 15
Angular - Directives
Consider this Angular template:
<div [ngSwitch]="day">
  <div *ngSwitchCase="1">Monday</div>
  <div *ngSwitchCase="2">Tuesday</div>
  <div *ngSwitchCase="3">Wednesday</div>
  <div *ngSwitchDefault>Other Day</div>
</div>

What will be displayed if day is 4?
AOther Day
BTuesday
CMonday
DNothing
Step-by-Step Solution
Solution:
  1. Step 1: Check if day matches any *ngSwitchCase

    Value 4 does not match 1, 2, or 3.

  2. Step 2: Use *ngSwitchDefault when no case matches

    The default block displays 'Other Day'.

  3. Final Answer:

    Other Day -> Option A
  4. Quick Check:

    No match triggers default display [OK]
Quick Trick: Default case shows when no match found [OK]
Common Mistakes:
  • Expecting no output if no case matches
  • Confusing numeric and string cases
  • Forgetting to include *ngSwitchDefault

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes