switch case in angular 8 example
Example 1: typescript switch case
let day : number = 4;
switch (day) {
case 0:
console.log("It is a Sunday.");
break;
case 1:
console.log("It is a Monday.");
break;
case 2:
console.log("It is a Tuesday.");
break;
case 3:
console.log("It is a Wednesday.");
break;
case 4:
console.log("It is a Thursday.");
break;
case 5:
console.log("It is a Friday.");
break;
case 6:
console.log("It is a Saturday.");
break;
default:
console.log("No such day exists!");
break;
}
Example 2: typescript switch
switch(expression) {
case constant-expression1: {
break;
}
case constant_expression2: {
break;
}
default: {
break;
}
}
Example 3: ngswitchcase in angular 8
content_copy
<container-element [ngSwitch]="switch_expression">
<some-element *ngSwitchCase="match_expression_1">...</some-element>
...
<some-element *ngSwitchDefault>...</some-element>
</container-element>