1

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' : '' .

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.