I'm trying to combine all my styles for a dropdown item into a single ng-class to reduce watchers, particularly like this...
ng-class="[button.icon, {'disabled': button.disableCallback(), 'hidden':button.hiddenCallback()}]
It gives a dropdown a button if it has an icon, but also defines disabled and hidden styles if they apply. Where button.icon could be any string like "add-icon" "remove-icon" etc. The other two just add disabled or hidden css class if the callback is true.
However, doing this I'm seeing the class being defined as just the object like...
class="[object Object]"
I think it's just adding the second object the {'disabled': button.disableCallback(), 'hidden':button.hiddenCallback()}
as the style since it's defined, thinking it's a string?
Is there a better way to do this? Have a dynamic class set on ng-class (the button.icon
), and add these conditional ones based on the callback (the {'disabled': button.disableCallback(), 'hidden':button.hiddenCallback()}
)