在 Angular 表达式中为三元运算符添加徽标
Add logo to ternary operators inside Angular Expressions
我想向我的 HTML 添加两个不同的徽标,具体取决于状态是否有效。
现在我有这个,有效:
<td>{{customer.activeStatus?"yes":"no"}}</td>
但我想要一些与此类似的东西:
<td>{{customer.activeStatus? "<i class='fas fa-lightbul'></i>":"no"}}</td>
如果是真的,我想从 FontAwesome 那里得到这个标志,如果是假的,那么 "no"。
你可以试试*ngIf and else
<td>
<i *ngIf="customer.activeStatus;else elsePart" class='fas fa-lightbul'></i>
<ng-template #elsePart>No</ng-template>
</td>
有关详细信息,请查看此 link
我想向我的 HTML 添加两个不同的徽标,具体取决于状态是否有效。
现在我有这个,有效:
<td>{{customer.activeStatus?"yes":"no"}}</td>
但我想要一些与此类似的东西:
<td>{{customer.activeStatus? "<i class='fas fa-lightbul'></i>":"no"}}</td>
如果是真的,我想从 FontAwesome 那里得到这个标志,如果是假的,那么 "no"。
你可以试试*ngIf and else
<td>
<i *ngIf="customer.activeStatus;else elsePart" class='fas fa-lightbul'></i>
<ng-template #elsePart>No</ng-template>
</td>
有关详细信息,请查看此 link