Question

I am aware that in angular you can do something like this:

<div ng-class="{myClassName: myCondition}"></div>

and Angular will add 'myClassName' to the class attribute if the condition is true.

I am also aware that:

<div ng-class="myClassName"></div>

will evaluate my 'myClassName' scope value and add it to the element's class argument.

Is there a way to do both of these at the same time on an element? If so, how?

Was it helpful?

Solution

I don't know if I understand you right,

<div ng-class="{myClassName: true}" class="{{myOtherClassName}}"></div>

controller

 $scope.myOtherClassName = "someClass";

The result should be:

<div   class="someClass myClassName"></div>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top