sam
sam

Reputation: 698

Change class in angularJS in ng-repeat

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

Upvotes: 0

Views: 76

Answers (1)

Deblaton Jean-Philippe
Deblaton Jean-Philippe

Reputation: 11396

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>

Upvotes: 3

Related Questions