5

I'm trying to set the class "expanded" to a div if the variable is undefined. I attempted this, but had no success. What am I doing wrong?

{'expanded': typeof member != 'undefined'}
2

2 Answers 2

11

You can do it easier:

 ng-class="{'expanded':  member != undefined}"

or even:

ng-class="{'expanded':  member }"

Example: http://plnkr.co/edit/9RMulfYViGKf91743VZz?p=preview

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

1 Comment

A, didn't even read properly too see that the problem was that Kristoffer wasn't using ng-class. This is a better answer than mine :-)
2

Place your condition inside a function in the scope.

Plunkr: http://plnkr.co/edit/JnH0H7

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.