The ng-switch directive allows us to conditionally insert or remove an element in the DOM.
There are 3 directives involved in the use of ng-switch:
If we take a look at the example everything will be clear. You add the ng-switch directive to a container element (a div in this case) and set the expression that acts as a selection condition (in this case we use the showNumber model variable). Then you add a ng-switch-when directive to every child element that you want to include or remove from the DOM specifying the condition that, if matched, makes the element included in the DOM. In case no condition is true among the ng-switch-when alternatives, the element included in the DOM will be the one with the ng-switch-default directive.
The ng-switch directive creates a new scope.