[SOLVED] Habpanel: Can't get nf-if working

I’ve got a widged in habpabel and trying to get ng-if working to change the colour of the test based on door open or closed.

<td ng-if="{{itemValue('Door_Front')}}=='OPEN'"><font color="red"><b>{{itemValue('Door_Front')}}</b></font></td>
<td ng-if="{{itemValue('Door_Front')}}=='CLOSED'"><font color="green"><b>{{itemValue('Door_Front')}}</b></font></td>

{{itemValue(‘Door_Front’)}} is printing out CLOSED, but on the above I’m seeing CLOSED printed out twice, once in red and then green.

I’ve also tried the solution from Ng-if should change color of indoor-temp according to co2 level, but doesnt work

but still not having any luck.

What am I missing?

Manange to get it working using this. Not sure why its working but will do more reading up :slight_smile:

<div ng-if="itemValue('Door_Front')=='OPEN'">
  <font color="red"><b>{{itemValue('Door_Front')}}</b></font>

<div ng-if="itemValue('Door_Front')=='CLOSED'">
  <font color="green"><b>{{itemValue('Door_Front')}}</b></font>

Maybe <td…> has to be part of <tr…> and that has to be part of <table…> and not stand alone was your problem?

Did some more googling on this, the problem is the div needs to be inside the td

So this works:

  <div ng-if="itemValue('Door_Front')=='OPEN'"><font color="red"><b>{{itemValue('Door_Front')}}</b></font></div>
  <div ng-if="itemValue('Door_Front')=='CLOSED'"><font color="green"><b>{{itemValue('Door_Front')}}</b></font></div>