The ng:class
allows you to set CSS class on HTML element dynamically by databinding an
expression that represents all classes to be added.
The directive won't add duplicate classes if a particular class was already set.
When the expression changes, the previously added classes are removed and only then the classes new classes are added.
<ANY ng:class="expression"> ... </ANY>
expression – {expression} –
Expression to eval. The result of the evaluation can be a string representing space delimited class names or an array.
<input type="button" value="set" ng:click="myVar='ng-input-indicator-wait'"> <input type="button" value="clear" ng:click="myVar=''"> <br> <span ng:class="myVar">Sample Text </span>
it('should check ng:class', function(){ expect(element('.doc-example-live span').prop('className')).not(). toMatch(/ng-input-indicator-wait/); using('.doc-example-live').element(':button:first').click(); expect(element('.doc-example-live span').prop('className')). toMatch(/ng-input-indicator-wait/); using('.doc-example-live').element(':button:last').click(); expect(element('.doc-example-live span').prop('className')).not(). toMatch(/ng-input-indicator-wait/); });