如何使用动态颜色来表示角度跨度

问题描述 投票:0回答:1

我在 html 文件中使用此变量作为颜色时遇到错误

 <span style=`color: ${_currentConfig.statusColor};`>{{ _currentConfig?.content }}</span>

这里出了什么问题?

main.js:1 DOMException: Failed to execute 'setAttribute' on 'Element': '${_currentConfig.statusColor};
' 不是有效的属性名称。`

html angular background-color
1个回答
0
投票

您可以使用Angular的绑定语法来动态设置样式。这是一个例子:

<span [style.color]="_currentConfig?.statusColor">{{ _currentConfig?.content }}</span>
© www.soinside.com 2019 - 2024. All rights reserved.