• 개요
@angular/common

NgSwitchCase

디렉티브
사용 중단 권고v20.0부터

Provides a switch case expression to match against an enclosing ngSwitch expression. When the expressions match, the given NgSwitchCase template is rendered. If multiple match expressions match the switch expression value, all of them are displayed.

사용 중단을 권고합니다.

Use the @case block within a @switch block instead. Intent to remove in a future major release

API

    
      class NgSwitchCase implements DoCheck {}
    
    

constructor

NgSwitchCase
@paramviewContainerViewContainerRef
@paramtemplateRefTemplateRef<Object>
@paramngSwitchNgSwitch
@returnsNgSwitchCase

ngSwitchCase

any
@deprecated

Use the @case block within a @switch block instead. Intent to remove in a future major release

Stores the HTML template to be selected on match.

설명

Provides a switch case expression to match against an enclosing ngSwitch expression. When the expressions match, the given NgSwitchCase template is rendered. If multiple match expressions match the switch expression value, all of them are displayed.

다음 모듈에서 내보냄

사용 시 참고사항

Within a switch container, *ngSwitchCase statements specify the match expressions as attributes. Include *ngSwitchDefault as the final case.

<container-element [ngSwitch]="switch_expression">
  <some-element *ngSwitchCase="match_expression_1">...</some-element>
  ...
  <some-element *ngSwitchDefault>...</some-element>
</container-element>

Each switch-case statement contains an in-line HTML template or template reference that defines the subtree to be selected if the value of the match expression matches the value of the switch expression.

As of Angular v17 the NgSwitch directive uses strict equality comparison (===) instead of loose equality (==) to match different cases.

상세 내용으로 이동