Home
Tutorials
Microsoft Technologies Tutorials
Java Programming Tutorials
Web Designing Tutorials
Script Programming Tutorials
Database Programming Tutorials
Mobile Technologies Tutorials
Other Programming Tutorials
Examples
Articles
Tools
News
AngularJS ng-switch Example
Keywords : Angularjs ng-switch-when multiple example, Angularjs ng-switch directive example, Angularjs ng switch when expression example, Angularjs ng-switch to show / hide elements example
Example
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> AngularJs ng-switch Directive Example </title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <script> var app = angular.module("AngularswitchApp", []); app.controller("ngswitchctrl", function ($scope) { $scope.items = ['one', 'two', 'three', 'four']; $scope.selectval = "one"; }); </script> </head> <body ng-app="AngularswitchApp"> <h2>AngularJS ng-switch Example</h2> <div ng-controller="ngswitchctrl"> Select Item: <select ng-model="selectval" ng-options="item for item in items"> </select> <div ng-switch on="selectval"> <div ng-switch-when="one"><b>DIV1</b>: You Selected value one</div> <div ng-switch-when="two"><b>DIV2</b>: You Selected value two</div> <div ng-switch-when="three"><b>DIV3</b>: You Selected value three</div> <div ng-switch-default>You are in default switch case.</div> </div> </div> </body> </html>
Click Here to See Result
Result
Previous
Next