ngClass style with dash in key

After hours of hacking around, it turns out the dash gets interpolated! Quotes are needed.

<i class="icon-home" ng-class="{'icon-white': someBooleanValue}">

UPDATE:

In older versions of Angular, using a backslash also does the trick, but not in the newer versions.

<i class="icon-home" ng-class="{icon\-white: someBooleanValue}">

The former is probably preferred, since you can more easily search for it in your favorite editor.

Leave a Comment