July 2017
Intermediate to advanced
454 pages
10h 1m
English
When we have to evaluate the expression based on multiple values, we make use of ngSwitch. An example of ngSwitch is shown in the following code snippet:
<div [ngSwitch]="taxRate"> <p *ngSwitchCase="'state'">State Tax</p> <p *ngSwitchCase="'fedral'">Fedral Tax</p> <p *ngSwitchCase="'medical'">Medical Tax</p> <p *ngSwitchDefault>Default</p></div>
Based on the value of taxRate, our application will decide which element to display. Let's update our example and add an *ngSwitch statement.
The updated example code is given as follows:
import {Component} from "@angular/core";@Component({ selector: 'structure-directive', templateUrl: 'structure-directive.component.html'})export class StructureDirectiveComponent { title = 'Structural ...Read now
Unlock full access