Change class in angularJS in ng-repeat

77 views Asked by At

I have two css classed triangle and triangleo

<div class="triangle" ng-repeat="chatdata in chats">
<p>{{chatdata.msg}}</p>
<p> {{chatdata.time}}</p>
</div>

So if chatdata.usrId == 123 class should be triangle else triangleo

1

There are 1 answers

1
Deblaton Jean-Philippe On BEST ANSWER

you can simply use ng-class

<div ng-class="chatdata.usrId === 123 ? 'triangle' : 'triangleo'" ng-repeat="chatdata in chats">
   <p>{{chatdata.msg}}</p>
   <p> {{chatdata.time}}</p>
</div>