Angular <a> tags are printed twice in ng-switch

时间:2018-05-16 19:32:40

标签: angular

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?

1 个答案:

答案 0 :(得分:-1)

ng-if在这种情况下有帮助。我改变了这一点,现在运作良好。