Home » AngularJS ng-switch Directive

AngularJS ng-switch Directive

by Online Tutorials Library

AngularJS ng-switch Directive

The AngularJS ng-switch directive facilitates you to hide/show HTML elements according to an expression. Child elements with the ng-switch-when directive will be displayed if it gets a match, otherwise the element, and its children will be removed.

If you want to define a default section you can use ng-switch-default directive.

Syntax:

Parameter explanation:

expression: It specifies an expression that will remove elements with no match, and display elements with a match.

Let’s take an example to demonstrate the usage of ng-swith directive.

See this example:

Test it Now

You may also like