Ng-if not working in ng-repeat

Hi everyone,

I am trying to set up a custom widget that lists the state of all my sensor batteries. The list is getting populated and the states are showing as text. However I want to add an image according to the current state using ng-if statements. I know the ng-if statements work in another widget that is not using ng-repeat. But what I am missing in this case:

<div class="row">
  <div class="col-sm-12"><h3 style="color: #ffaa00; line-height: .1em;">Battery States</h3></div>
    <table class="table">
    <tr ng-repeat="item in itemsInGroup(config.group_item) | orderBy:'label'">
      <td class="text-right">{{item.label}}</td>
      <td>
        <div ng-if="{{itemState(item.name)}}=='ON'">test on

        </div>
        <div ng-if="{{itemState(item.name)}}=='OFF'">test off

        </div>
        <div ng-if="{{itemState(item.name)}}=='UNDEF'">test undef

        </div>
      </td>
      <td class="text-left">{{itemState(item.name)}}</td>
    </tr>
    </table> 
</div>

What I’m getting is this.

The dummy text "test on|test off|test undef do not appear. Does anyone see why?

Thanks for any help.

Rob

You may try if the ng-if expression that is used in this example Widget positioning elements helps to solve your question.

Hey Wolfgang,

you are my hero for today. My ng-if statements are now working. Your help is greatly appreciated.

Thanks

Rob

1 Like