angular.module.ng.$compileProvider.directive.ngStyle

Description

The ngStyle directive allows you to set CSS style on an HTML element conditionally.

Usage

as attribute
<ANY ng-style="{expression}">
   ...
</ANY>
as class
<ANY class="ng-style: {expression};">
   ...
</ANY>

Parameters

Example

   <input type="button" value="set" ng-click="myStyle={color:'red'}">
   <input type="button" value="clear" ng-click="myStyle={}">
   <br/>
   <span ng-style="myStyle">Sample Text</span>
   <pre>myStyle={{myStyle}}</pre>
  it('should check ng-style', function() {
    expect(element('.doc-example-live span').css('color')).toBe('rgb(0, 0, 0)');
    element('.doc-example-live :button[value=set]').click();
    expect(element('.doc-example-live span').css('color')).toBe('rgb(255, 0, 0)');
    element('.doc-example-live :button[value=clear]').click();
    expect(element('.doc-example-live span').css('color')).toBe('rgb(0, 0, 0)');
  });