我有下面的代码行,其中有两个值缺席和Present.If的值是缺席的,我想使它红色和粗体。我尝试应用样式,但它不是working.please建议我怎么做。
代码:
<div class="flex-2 bold1">{{attendance.status == 'Absent' ? "style='color:red;font-weight:bold'" :" "}}</div>发布于 2018-04-16 18:43:28
有两种方法可以做到这点:
<div class="flex-2 bold1" ng-style="attendance.status == 'Absent' && {'color':'red','font-weight':'bold'}"></div>另一种是使用class (推荐)
.highlighted {
color:red;
font-weight:bold
}
ng-class="{'highlighted': attendance.status == 'Absent'}"发布于 2018-04-16 19:00:18
使用class (推荐):在class中创建样式,并使用条件运算符在ng-class中引用它
ng-class="{attendance.status ==‘缺席’?‘测试’:'test1'}“
https://stackoverflow.com/questions/49855135
复制相似问题