1

I have this piece of code in a ASP.NET MVC view:

<div ng-repeat="it in (@source)">
            <button class="btn hvr-glow btn-success" >
                {{it.name}}
                <p ng-if="it.check==true"><i class="fa fa-check-circle-o" ng-click="it.check=false"></i></p>
                <p ng-if="it.check==false'"><i class="fa fa-circle-o" ng-click="it.check=true"></i></p>       
            </button>                               
        </div> 

source is a list of objects of type ApplicationStatus, which contain a boolean field named check. I want to change the type of the font awesome icon on click. But I don't see the icons. Source is correctly loaded. Where is the problem ?

Karl
  • 39
  • 2
  • 5

2 Answers2

1

You can use ng-class for that. For example:

<i ng-class="{'fa fa-check-circle-o': check, 'fa fa-circle-o': !check}"

Here's another question related to ng-class

Note - a ternary operator would probably be best in your case

Community
  • 1
  • 1
Katana24
  • 8,706
  • 19
  • 76
  • 118
0
<div ng-repeat="it in source">
  <button class="btn hvr-glow btn-success" ng-click="it.check = !it.check">
          {{it.name}}
      <p>
        <i ng-class="{'fa fa-check-circle-o': it.check, 'fa fa-circle-o': !it.check}"></i>
      </p>
  </button>
 </div>
Bata
  • 651
  • 3
  • 7