Reputation: 161
Is it possible to combine a data-bind class and a conditional class in the same ng-class
?
Ex:
<div class="trow" ng-class="rowClass($index), data.accounts[k.id].checked ? 'checked' : '' " ng-repeat="k in accounts | filter:{location_id: location.id}">
This isn't working for me and neither
ng-class="{rowClass($index), data.accounts[k.id].checked ? 'checked' : '' }"
I want to have both classes, the data-binded rowClass($index)
and also the conditional data.accounts[k.id].checked ? 'checked' : ''
.
Upvotes: 1
Views: 66
Reputation: 48968
Use an array to combine the two:
ng-class="[rowClass($index), data.accounts[k.id].checked ? 'checked' : '' ]"
For more information, see AngularJS ng-class Directive API Reference.
Upvotes: 2