javascript - 如何根据通过打字稿显示的动态更改图标条件?
问题描述
我使用材料图标的名称通过打字稿显示图标。我想根据情况更改图标。就像在打字稿中说的那样,图标的名称是“power_off”
if power is false then we want to use 'power_off' but if the power is true then we want to use 'power'
,。我正在为此类代码使用另一个组件,但它与该组件连接,并且该组件中的名称正在更改,但在视图中它没有更改。这个你能帮我吗。先感谢您。
{name: 'associateDriver', visible: true, tooltip: 'Associate Driver', icon: 'person', type: 'icon'},
{name: 'associateServiceReminder', visible: true, tooltip: 'Service Reminder', icon: 'add_alert', type: 'icon'},
{name: 'busStopStatus', visible: false, tooltip: 'Bus Stop Status', icon: 'pin_drop', type: 'icon'},
{name: 'delete', visible: false, tooltip: 'Delete', icon: 'delete', type: 'icon'},
{name: 'immobilize', visible: true, tooltip: 'Immobilize', icon: 'power_off', type: 'icon'}
解决方案
我希望这有帮助
<div>
<mat-icon *ngIf="power">power_on<mat-icon>
<mat-icon *ngIf="!power">power_off<mat-icon>
</div>
推荐阅读
- java - 具有一列的 GridView 图像
- android - 使用原始图像的纵横比(如whatsapp)设置ImageView的宽度和高度
- webpack-4 - 将 webpack 配置导出为函数失败
- r - Assigning tick marks frequency to discrete data axes in facet_grid
- mysql - 使用 Sequel Pro 创建和链接数据库
- c++ - 错误:聚合 std::promise 类型不完整且无法定义
- vba - Excel VB 高级筛选条件复制
- django - 从一对多字段中获取 ID
- python - 使用 BeautifulSoup 解析脚本标签内的 json 文本
- sql - Oracle:TABLE 语法有什么作用?