What is ng-Switch
The ng-Switch directive will used for condition swap the DOM elements. This directive is support the scope of angular variable, The DOM is enable means when the matched ng-switch-when properties is equal. This properties compare into String only.
ng-switch-when case more than matched DOM value also return. It will like unique and duplicated both will return from the ng-switch directive.
HTML :
<div ng-app="switchApp">
<div ng-controller="SwitchCtrl">
<div ng-switch= "grade">
<div ng-switch-when="A">You got A Grade</div>
<div ng-switch-when="B">You got B Grade</div>
<div ng-switch-when="C">You got C Grade</div>
<div ng-switch-when="D">You got D Grade</div>
<div ng-switch-when="E">You got E Grade</div>
<div ng-switch-default>Fail</div>
</div>
</div>
</div>
Angular Code :
var app = angular.module('switchApp',[]);
app.controller('SwitchCtrl',function($scope){
$scope.grade = "C";
});
Comments
Post a Comment