更新时间:2023-01-24 15:54:58
改变字体颜色有两种解决方案,但取决于您的要求
There are two solutions to change font color but depends on you requirement
NgStyle
指令,它为您更新 HTML 元素样式..NgStyle
Directive which Update an HTML element styles for you..NgStyle 指令示例:
<span [ngStyle]="{'color': proportion === '100' ? 'green' : 'red'}"></span>
---------------------- OR -----------------------------------
<span [style.color]="proportion === '100' ? 'green' : 'red'"></span>
NgClass
指令,该指令在 HTML 元素上添加和删除 CSS 类...NgClass
Directive which Adds and removes CSS classes on an HTML element...NgClass 指令示例:
<span [ngClass]="{proportion === '100' ? 'green': 'red'}"></span>