AngularJS Tutorial - Show hide with ng-hide








The following code shows how to Show hide with ng-hide.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
function ClickToEditCtrl($scope) {<!--   w w  w.jav a  2 s  . c  o m-->
  $scope.title = "Welcome to this demo!";
}
</script>
</head>
<body>
  <div ng-app>
  <div ng-controller="ClickToEditCtrl">
    <div ng-hide="editorEnabled">
      {{title}}
      <a href="#" ng-click="editorEnabled=!editorEnabled">Edit title</a>
    </div>
    <div ng-show="editorEnabled">
      <input ng-model="title">
      <a href="#" ng-click="editorEnabled=!editorEnabled">Done editing?</a>
    </div>
  </div>
</div>
</body>
</html>

The code above is rendered as follows: