AngularJS ng-hide – conditionally hide an element

AngularJS directive ng-hide hides an element if the expression ng-hide evaluates to true. Under the hood it adds or removes class ng-hide to the element. The .ng-hide CSS class is predefined in AngularJS and sets the display style to none (using an !important flag).

<div ng-app="myApp" ng-controller='MyCtrl'>
  <label>Select checkbox to hide: <input type="checkbox" ng-model="doHide"></label><br/>
  <span ng-hide="doHide"><strong>Hide this text</strong></span>

<script src="//"></script>
  var module = angular.module('myApp', []);
  module.controller('MyCtrl', function($scope) {});
Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit


Click here to write/view comments