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!
Angular's NgClass Directive So far we've looked at adding just single classes, which is something the NgClass directive can also help us with as it supports multiple classes. Using multiple classes is the real reason to use the NgClass directive. You can think of NgClass as being able to specify multiple [class.
javascript - ng-if and ng-class-even/odd doesn't work well together and won't get expected outout - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.
From the docs:
<some-element [ngClass]="stringExp|arrayExp|objExp">
which means one of stringExp|arrayExp|objExp
(but not two of ;-) )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With