I am using Angular and I have to make a switch on iterate collection.
Unfortunetally following code print always both <a>
tags.
<li *ngFor="let element of account.collection" >
<div [ngSwitch]=element.anyValue>
<a *ngSwitchCase="A" [routerLink]="['../A', element.id ]"><span>One</span></a>
<a *ngSwitchCase="B" [routerLink]="['../B', element.id ]"><span>Two</span></a>
</div>
</li>
any ideas?
答案 0 :(得分:-1)
ng-if在这种情况下有帮助。我改变了这一点,现在运作良好。