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>
        <div ng-if="{{itemState(}}=='ON'">test on

        <div ng-if="{{itemState(}}=='OFF'">test off

        <div ng-if="{{itemState(}}=='UNDEF'">test undef

      <td class="text-left">{{itemState(}}</td>

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.


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.



1 Like