I try to find out the good syntax for adding classes depending on angular values. I want to activate a class regarding 2 conditions (one on live user changes, and one on loading datas) with a OR operator.
Here is the line :
 <a href="" ng-click="addFavorite(myfav.id);favorite=!favorite">     <i class="fa orange" ng-class="{'fa-star': (favorite || (fav==myfav.id)), 'fa-star-o': !favorite}"></i>  </a>   I tried some different codes like this one :
 ng-class="{'fa-star': favorite, 'fa-star': (fav==myfav.id), 'fa-star-o': !favorite}"   without any success. Can someone help me finding the good syntax ?
Try this.
<a href="" ng-click="addFavorite(myfav.id);favorite=!favorite">  <i class="fa orange" ng-class="{'fa-star': favorite || fav==myfav.id, 'fa-star-o': !favorite}"></i>   
No need the brackets.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With