angular/tools/manual_api_docs/blocks/switch.md
Jeremy Elbourn 64db486edc build: add rules for generating block/element API data (#52480)
Adds build rules for "artificially" generating `DocEntry` collections for block and element APIs. The two rules are very similar, but _just_ different enough that it's worth having two separate implementations.

PR Close #52480
2023-11-02 11:02:08 -07:00

705 B

The @switch block is inspired by the JavaScript switch statement:

Syntax

@switch (condition) {
  @case (caseA) {
    Case A.
  }
  @case (caseB) {
    Case B.
  }
  @default {
    Default case.
  }
}

Description

The @switch blocks displays content selected by one of the cases matching against the conditional expression. The value of the conditional expression is compared to the case expression using the === operator.

The @default block is optional and can be omitted. If no @case matches the expression and there is no @default block, nothing is shown.

@switch does not have fallthrough, so you do not need an equivalent to a break or return statement.