Suggest an editImprove this articleRefine the answer for “What does the ngSwitch directive do?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)The `ngSwitch` directive in Angular is a structural directive that lets you **display one of several element variants** depending on the value of an expression. **Key point:** `ngSwitch` controls the selection of one of several elements in the DOM based on the value of an expression.Shown above the full answer for quick recall.Answer (EN)ImageThe `ngSwitch` directive in Angular is a structural directive that lets you **display one of several element variants** depending on the value of an expression. How it works: 1. `[ngSwitch]="expression"` is used on the parent element. 2. Child elements with `*ngSwitchCase="value"` are placed inside for specific variants. 3. You can specify `*ngSwitchDefault` for the case when no case matches. Example: ```html <div [ngSwitch]="color"> <p *ngSwitchCase="'red'">Red is selected</p> <p *ngSwitchCase="'blue'">Blue is selected</p> <p *ngSwitchDefault>No color selected</p> </div> ``` If `color = 'blue'`, Angular renders only `<p>Blue is selected</p>`. > Conclusion: `ngSwitch` controls **the selection of one of several elements** in the DOM based on the value of an expression.For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.