Javascript 如何根据通过typescript显示的条件动态更改图标?

Javascript 如何根据通过typescript显示的条件动态更改图标?,javascript,angular,typescript,command-line-interface,Javascript,Angular,Typescript,Command Line Interface,我使用材质图标的名称通过typescript显示图标。我想根据条件更改图标。 像在typescript中一样,图标的名称是“电源关闭”, 如果power为false,则我们希望使用“power\u off”,但如果power为true,则我们希望使用“power”。 我正在使用另一个组件来编写这样的代码,但它与该组件相连,并且该组件中的名称正在更改,但在视图中它没有更改。 请帮我解决这个问题。 先谢谢你 {name: 'associateDriver', visible: true, toolt

我使用材质图标的名称通过typescript显示图标。我想根据条件更改图标。 像在typescript中一样,图标的名称是“电源关闭”,
如果power为false,则我们希望使用“power\u off”,但如果power为true,则我们希望使用“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'}

我希望这有助于大家分享你迄今为止所做的一切!请显示您的代码,而不是代码说明。下次请提供代码。对于.html和.tsI,我认为问题在于
此组件中的名称正在更改,但在视图中它没有更改。不确定这是否有用,直到OP展示他们的代码,我们才知道。展示你的代码,我无法想象你的代码是什么样子。这只是你的数据源,不是你的代码。另外,请编辑您的原始问题,不要在下面的评论中添加此内容。Jeremy Thille您是对的,它没有改变,这就是我想做的…请建议您是否可以提供帮助。