what is ng-switch

Ng-switch is conditional directives which swap (show and hide) DOM elements according to expression. We use ng-switch-when to check conditions and ng-switch-default to put default condition.

Example of ng-switch

in the following example we are going to find out the vowels using ng-switch.

    <title>Untitled Document</title>
    <meta charset="UTF-8">
    <script src="angular.js"></script>
<body ng-app>

    <input type="text" ng-model="n1">
    //switch the variable
    <div ng-switch="n1">
        <div ng-switch-when="a">It is vowel</div>
       <div ng-switch-when="i">It is vowel</div>
           <div ng-switch-when="e">It is vowel</div>
           <div ng-switch-when="o">It is vowel</div>
           <div ng-switch-when="u">It is vowel</div>
           <div ng-switch-default>It is constant</div>