1
ng-class="{'active' : question.chosen == key}"

The above sets my class as active when question.chosen matches key. This means that $scope.question.chosen only has a single value.

In the even $scope.question.chosen has ["a","b","c"] how would I iterate through that with ng-class to match key?

2 Answers 2

2

You can try:

ng-class="{ 'active' : question.chosen.indexOf(key) >= 0 }"
Sign up to request clarification or add additional context in comments.

Comments

0

You can have the ng-class object have keys as class names and values as functions that return booleans.

I set up a fiddle for you:

    <li ng-class="{'active': isActive('one')}">one</li>

http://jsfiddle.net/DrDyne/gZg7q/2/

Tell me if this helps :)

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.