angular.widget.ng:switch

Work in Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

Description

Conditionally change the DOM structure.

Usage

In HTML Template Binding

<ng:switch on="..."></ng:switch>

Parameters

Example

  <select name="switch">
    <option>settings</option>
    <option>home</option>
    <option>other</option>
  </select>
  <tt>switch={{switch}}</tt>
  </hr>
  <ng:switch on="switch" >
    <div ng:switch-when="settings">Settings Div</div>
    <span ng:switch-when="home">Home Span</span>
    <span ng:switch-default>default</span>
  </ng:switch>
  </code>
  it('should start in settings', function(){
   expect(element('.doc-example-live ng\\:switch').text()).toEqual('Settings Div');
  });
  it('should change to home', function(){
   select('switch').option('home');
   expect(element('.doc-example-live ng\\:switch').text()).toEqual('Home Span');
  });
  it('should select deafault', function(){
   select('switch').option('other');
   expect(element('.doc-example-live ng\\:switch').text()).toEqual('default');
  });