@switch
Built-in control flow block selecting one case by value.
Syntax
@switch (expr) { @case (v) { ... } @default { ... } } Parameters
| Name | Type | Required | Description |
|---|---|---|---|
expr | any | No | Value compared against each @case using strict equality. |
Returns
template block — Renders the matching case or @default.
Examples
@switch (status()) {
@case ('loading') { <app-spinner /> }
@case ('error') { <p>Failed</p> }
@default { <app-content /> }
}
Notes
`@switch` replaces `[ngSwitch]`. Cases are matched with `===`. Only the first
matching `@case` renders; `@default` is optional and renders when no case
matches. No fall-through between cases.