我正在使用 Material 图标的名称通过 typescript 显示图标。我想根据条件更改图标。
就像在 typescript 中一样,图标的名称是“power_off”,
如果 power 为 false,那么我们要使用“power_off”,但如果 power 为 true,那么我们要使用“power”
。
我正在为此类代码使用另一个组件,但它与该组件相连,并且该组件中的名称正在更改,但在 View 中它没有更改。
这个你能帮我吗。
提前谢谢你。
{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>
关于javascript - 如何根据 typescript 显示的动态条件更改图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55393222/