如何根据角度条件显示不同的模板

时间:2019-10-01 06:59:29

标签: angular

我正在做有角度的项目。在ts文件中,我正在获取字符串值数组。根据条件,我可能会得到3种类型的字符串,而且一次我只会在数组中获得一个字符串值。可能是“ First”或“ Second”或“ Third”。如果我将得到“ First”,则需要显示不同的模板,Second或Third则需要显示不同的模板。我没有得到如何在HTML文件上应用此条件。任何帮助,请!!!!!!

1 个答案:

答案 0 :(得分:3)

<ng-container *ngIf="condition1">Condition 1 stuff</ng-container>
<ng-container *ngIf="condition2">Condition 2 stuff</ng-container>
<ng-container *ngIf="condition3">Condition 3 stuff</ng-container>
相关问题