I notices that when I mix ng-class
with class + expression (class="something-{{ stuff }}")
which might not be set, the ng-class
is not getting compiled.
Example:
This will work OK (JSFIDDLE)
<div
ng-controller="MainCtrl"
ng-class="(data.size > 10) ? 'font-large' : 'font-small'"
>
Lorem ipsum dolor sit amet
But when I use ng-class & class with expression (which does not exist on the scope) it will not work, it will not run/compile ng-class
. (JSFIDDLE):
<div
ng-controller="MainCtrl"
class="just-a-class color-{{ data.color }}"
ng-class="(data.size > 10) ? 'font-large' : 'font-small'"
>
Lorem ipsum dolor sit amet.
</div>
Is there any way to use both ng-class
and class with expression
or what is the workaround? Any suggestions much appreciated.
just-a-class color-red font-small
– kasoban Sep 16 at 9:08