AngularJS Tutorial - ng-switch








ng-switch-when and on="propertyName" switches directives render for given propertyName.

ng-switch-default outputs the name of the person until the switch occured.

Example

The following code shows how to use ng-switch.

In the following example, when person.name is 'A' the div below the text field will be shown:

<input type="text"  ng-model="person.name" />
<div ng-switch  on="person.name">
     <p  ng-switch-default>Value:</p>
     <h1  ng-switch-when="A">Hi</h1>
</div>