Ng-Show-Ng-Hide-1

 

We have a checkbox to hide show the textbox. The textbox will show when the checkbox is checked and if we un-check the checkbox then the value of isChecked variable is false and if we assign false value to the ng-show directive it will hide the div tag.

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app="Demo"> <div class="row" ng-controller="myController"> <span class="col-md-3"> <span>Hide/Show</span> <input type="checkbox" ng-model="isChecked" /> </span> <div class="col-md-9" ng-show="isChecked"> <input type="text" style="width:300px;" class="form-control" /> </div> </div> <script type="text/javascript"> var demo = angular.module("Demo", []); demo.controller("myController", function ($scope) { $scope.isChecked = true; }); </script> </body> </html>
Output