angular - 向 Angular 表达式中的三元运算符添加徽标
问题描述
我想根据状态是否处于活动状态向我的 HTML 添加两个不同的徽标。
现在我有这个,它有效:
<td>{{customer.activeStatus?"yes":"no"}}</td>
但我想有一些类似的东西:
<td>{{customer.activeStatus? "<i class='fas fa-lightbul'></i>":"no"}}</td>
如果是真的,我想从 FontAwesome 获得这个标志,如果是假的,那么“不”。
解决方案
你可以试试*ngIf and else
<td>
<i *ngIf="customer.activeStatus;else elsePart" class='fas fa-lightbul'></i>
<ng-template #elsePart>No</ng-template>
</td>
有关更多详细信息,请查看此链接
推荐阅读
- maven - 在 Karaf 容器中打包和部署 OSGi 包和 Karaf 功能
- javascript - Gmail 拒绝呈现图像背景 url 属性
- java - 分离实体传递给坚持:不允许我保存对象
- python - 创建一个字典,名字作为键,与键关联的全名作为值
- android - 在明确删除之前,SingleValueEvent 侦听器是否计入 Firebase RealTime DB 中的“同时连接”?
- php - Laravel 5.6 - 禁用错误
- python - 通过 pyodbc 使用服务帐户修复 sql 连接问题需要帮助
- kubernetes - 守护程序集和部署之间的区别
- javascript - JsPDF - 无法读取未定义的属性“charAt”
- c# - C# 自安装 windows 服务