Home > DeveloperSection > Forums > use ngSwitch in angular js.
Ankit Singh

Total Post:341

Points:2389
Posted on    March-01-2016 10:22 PM

 Angular JS Angular JS 
Ratings:


 1 Reply(s)
 285  View(s)
Rate this:
we want to use  ngSwitch in angular js. how to use this please help me.


aditya kumar Patel

Total Post:250

Points:1782
Posted on    March-01-2016 10:27 PM

@{

Layout = null;

}

<!DOCTYPE html>

<html>

<head>

<title>Forum</title>

<meta name="viewport" content="width=device-width" />

<title></title>

<script src="~/Scripts/jquery-2.1.4.js"></script>

<script src="~/Scripts/angular.js"></script>

<script>

var app = angular.module('myapp', []);

app.controller('Controller', ['$scope', function ($scope) {

$scope.items = ['Home', 'About', 'Contact','Product'];

$scope.selection = $scope.items[0];

}]);

</script>

</head>

<body ng-app="myapp">

<div ng-controller="Controller" style="width:400PX;">

<select ng-model="selection" ng-options="item for item in items">

</select>

<code>selection={{selection}}</code>

<hr/>

<div class="container"

ng-switch on="selection">

<div class="switch" ng-switch-when="Home">Home Div</div>

<div class="switch" ng-switch-when="About">About Div</div>

<div class="switch" ng-switch-when ="Contact">Contact Div</div>

<div class="switch" ng-switch-when="Product">Product Div</div>

</div>

</div>

<style>

.container {

position:relative;

background:white;

border:1px solid black;

height:40px;

overflow:hidden;

width:400px;

}

</style>

</body>

</html>

 


Don't want to miss updates? Please click the below button!

Follow MindStick