Bird
0
0

Given this Angular template snippet:

medium📝 component behavior Q13 of 15
Angular - Directives
Given this Angular template snippet:
<div [ngSwitch]="color">
  <div *ngSwitchCase="'red'">Stop</div>
  <div *ngSwitchCase="'green'">Go</div>
  <div *ngSwitchCase="'yellow'">Wait</div>
  <div *ngSwitchDefault>Unknown</div>
</div>

What will be displayed if color = 'yellow'?
AGo
BWait
CStop
DUnknown
Step-by-Step Solution
Solution:
  1. Step 1: Identify the value of color

    The variable color is set to 'yellow'.
  2. Step 2: Match color with *ngSwitchCase values

    The case *ngSwitchCase="'yellow'" matches the value.
  3. Final Answer:

    Wait -> Option B
  4. Quick Check:

    color='yellow' shows 'Wait' = A [OK]
Quick Trick: Match the variable value exactly with ngSwitchCase string [OK]
Common Mistakes:
  • Choosing default when a case matches
  • Confusing case strings with variables
  • Ignoring quotes around case values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes