Skip to main content

Posts

Showing posts with the label @default block

Angular 17 switch case Example | @switch block selection | @default block

B Built-in control flow and the NgIf, NgSwitch and NgFor structural directives: 1.      The @if block replaces *ngIf for expressing conditional parts of the UI. 2.      The @switch block replaces ngSwitch with major benefits. 3.      The @for block replaces *ngFor for iteration, and has several differences compared to its structural directive NgFor predecessor. 4.      The track setting replaces NgFor's concept of a trackBy function. The improved ergonomics is even more visible with   *ngSwitch: The new control flow enables significantly better type-narrowing in the individual branches in @switch, which is impossible in  *ngSwitch. Before Angular 17, <div [ngSwitch]="accessLevel">   <admin-dashboard *ngSwitchCase="admin"/>   <moderator-dashboard *ngSwitchCase="moderator"/>   <user-dashboard *ngSwitchDefault/> </div> From Angular 17:  Which w...