Abraham P Abraham P - 2 months ago 19
AngularJS Question

complex ng-class expression containing both a value and a conditional

Say I wanted to have an ng-class do two things:

1) populate a value from a variable like so



2) conditionally set a predefined class:

`ng-class = "{awesomeClass: myAwesomeBoolean}`

I am aware that I could do something like
class="{{myAwesomeJavaScriptVariable}}" ng-class="{awesomeClass: myAwesomeBoolean}"

How (if this is even possible) could I amalgamate those two into a single ng-class expression?


@Abraham P:

To Set Both the Conditional Statement and Scope Variable as Class

ng-class="[{awesomeClass: myAwesomeBoolean},myAwesomeJavaScriptVariable]"

This Will Work Fine.