ng-show/ng-hide

Description

ng-show and ng-hide show or hide the HTML element based its expression.

The show or hide is controled by the ng-hide CSS class.

The .ng-hide CSS class is predefined in AngularJS and sets the display style to none.

Example

The following code shows how to ng-show/ng-hide.


<!--from  www .ja  v  a  2 s . c  om-->

<!doctype html>
<html ng-app="myApp">
<head>
  <link rel="stylesheet" href="http://cdn.jsdelivr.net/foundation/4.3.2/css/foundation.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.js"></script>
</head>
<body>

  <div ng-show="2 + 2 == 5">don't show</div>
  <div ng-show="2 + 2 == 4">show</div>

  <div ng-hide="2 + 2 == 5">don't hide</div>
  <div ng-hide="2 + 2 == 4">do hide</div>

  <script>
    angular.module('myApp', []);
  </script>

</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Tutorial »




Introduction
Buildin Filters
Buildin Directives