I am trying to use ngSwitch within ngFor and it doesn't seem to be working. Below is the Test code I Have written (Note: i am using Devextreme UI, hence the dx-* tags)
<dx-tab-panel
#tabPanel
[dataSource]="companies"
[selectedIndex]="0"
[loop]="false"
[animationEnabled]="true"
[swipeEnabled]="true"
>
<dxi-item [title]="item.Title" *ngFor="let item of currView">
<ng-container [ngSwitch]="item.Title">
<ng-container *ngSwitchCase="TARs">
<p>TEST</p>
</ng-container>
<iframe *ngSwitchDefault [src]="item.Src | safeUrl"></iframe>
</ng-container>
</dxi-item>
</dx-tab-panel>
答案 0 :(得分:3)
You need to give single quotes 'TARs'
for string literals else it takes as a variable which will be undefined.
<ng-container *ngSwitchCase="'TARs'">
<p>TEST</p>
</ng-container>
Since it was getting undefined in switch case, it was going to default.