![](/img/trans.png)
[英]How to take different templates as an input based on condition using ngTemplateOutlet in angular
[英]How to display different templates based on condition in angular
我在 angular 做项目。 在 ts 文件中,我得到了字符串值的数组。 根据条件,我可能会得到 3 种类型的字符串。一次我只会在数组中得到一个字符串值。 那可能是“第一”或“第二”或“第三”。如果我得到“第一”意味着我需要显示不同的模板,第二或第三意味着我需要显示不同的不同模板。 我不知道如何在 html 文件上应用此条件。 任何帮助请!
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.