Monochromie Monochromie - 2 years ago 77
AngularJS Question

How to set dynamic class name with complex statement in ng-class?

That's what I have:

ng-class="[{loading:loadingIsOn},{ color:true}]"

I have problem with color variable. It holds string value of defined color, but I can not pass it to HTML.

By the way,


works fine.

Answer Source

If loadingIsOn is true, and color is 'green', and you want class="loading, green", then all you need is

ng-class="[{loading:loadingIsOn}, color]"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download