0

I am having the below line of code which is having two values Absent and Present.If the value is Absent i want make it red colour and bold.I tried by applying style but it is not working.please suggest me how to do it .

code:

<div class="flex-2 bold1">{{attendance.status == 'Absent' ? "style='color:red;font-weight:bold'" :" "}}</div>

2 Answers2

1

There are two ways to do that:

<div class="flex-2 bold1" ng-style="attendance.status == 'Absent' && {'color':'red','font-weight':'bold'}"></div>

Other is by using class (Recommended)

.highlighted {
    color:red;
    font-weight:bold
}


ng-class="{'highlighted': attendance.status == 'Absent'}"
Ghazni
  • 826
  • 8
  • 16
0

using class (Recommended): Create the style in class and mention it in ng-class with conditional operator

ng-class="{attendance.status == 'Absent'?'test': 'test1'}"

Gokul
  • 1
  • 1