5

In angular 1.x, I can use a combination of the array and object syntax in the same statement, like this:

<div ng-class="[classNameFromController, {'show' : booleanFromController}]"></div>

The same does not work in Angular 2 with the same approach:

<div [ngClass]="[classNameFromController, {'show' : booleanFromController}]"></div>

I can't find anything that suggests it can be done.

What gives?

Cheers!

1 Answer 1

6

From the docs:

<some-element [ngClass]="stringExp|arrayExp|objExp">

which means one of stringExp|arrayExp|objExp (but not two of ;-) )

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.