<h1><code ng:non-bindable="">ngSwitch</code>
<span class="hint">(directive in module <code ng:non-bindable="">ng</code>
)</span>
</h1>
<div><h2 id="Description">Description</h2>
<div class="description"><p>Conditionally change the DOM structure.</p></div>
<h2 id="Usage">Usage</h2>
<div class="usage">as element (see <a href="guide/ie">IE restrictions</a>)<pre class="prettyprint linenums">&lt;ng-switch
       on="{*}"&gt;
&lt;/ng-switch&gt;</pre>
as attribute<pre class="prettyprint linenums">&lt;ANY ng-switch="{*}"&gt;
   ...
&lt;/ANY&gt;</pre>
<h3 id="Directive.info">Directive info</h3>
<div class="directive-info"><ul><li>This directive creates new scope.</li>
</ul>
</div>
<h3 id="Parameters">Parameters</h3>
<ul class="parameters"><li><code ng:non-bindable="">ngSwitch|on – {*} – </code>
<p>expression to match against <tt>ng-switch-when</tt>.</p></li>
</ul>
</div>
<h2 id="Example">Example</h2>
<div class="example"><h3>Demo Source Code</h3>
<div source-edit="" source-edit-deps="angular.js script.js" source-edit-html="index.html-157" source-edit-css="" source-edit-js="script.js-156" source-edit-unit="" source-edit-scenario="scenario.js-158"></div>
<div class="tabbable"><div class="tab-pane" title="index.html">
<pre class="prettyprint linenums" ng-set-text="index.html-157" ng-html-wrap=" angular.js script.js"></pre>
<script type="text/ng-template" id="index.html-157">
  
  <div ng-controller="Ctrl">
    <select ng-model="selection" ng-options="item for item in items">
    </select>
    <tt>selection={{selection}}</tt>
    <hr/>
    <div ng-switch on="selection" >
      <div ng-switch-when="settings">Settings Div</div>
      <span ng-switch-when="home">Home Span</span>
      <span ng-switch-default>default</span>
    </div>
  </div>
</script>
</div>
<div class="tab-pane" title="script.js">
<pre class="prettyprint linenums" ng-set-text="script.js-156"></pre>
<script type="text/ng-template" id="script.js-156">
    function Ctrl($scope) {
      $scope.items = ['settings', 'home', 'other'];
      $scope.selection = $scope.items[0];
    }
  </script>
</div>
<div class="tab-pane" title="End to end test">
<pre class="prettyprint linenums" ng-set-text="scenario.js-158"></pre>
<script type="text/ng-template" id="scenario.js-158">
  it('should start in settings', function() {
   expect(element('.doc-example-live [ng-switch]').text()).toMatch(/Settings Div/);
  });
  it('should change to home', function() {
   select('selection').option('home');
   expect(element('.doc-example-live [ng-switch]').text()).toMatch(/Home Span/);
  });
  it('should select deafault', function() {
   select('selection').option('other');
   expect(element('.doc-example-live [ng-switch]').text()).toMatch(/default/);
  });
</script>
</div>
</div><h3>Demo Source Code</h3>
<div class="well  doc-example-live" ng-embed-app="" ng-set-html="index.html-157" ng-eval-javascript="script.js-156"></div></div>
</div>
