AngularJS Basic ng hide Directive Usage and Sample Code
- 2021-07-07 06:09:36
- OfStack
AngularJS ng-hide Directive
AngularJS instance
Hide Part 1 when the check box is selected:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
</head>
<body ng-app="">
Hide HTML: <input type="checkbox" ng-model="myVar">
<div ng-hide="myVar">
<h1>Welcome</h1>
<p>Welcome to my home.</p>
</div>
</body>
</html>
Definition and usage
The ng-hide directive hides the HTML element when the expression is true.
ng-hide is a predefined class for AngularJS, setting the element's display to none.
Grammar
<
element ng-hide="expression"
>
<
/element
>
As an CSS class:
<
element class="ng-hide"
>
<
/element
>
All HTML elements support this instruction.
Parameter value
值 | 描述 |
---|---|
expression | 表达式如果返回 true 则隐藏元素。 |
The above is the basic knowledge of AngularJS ng-hide instruction, which will be supplemented later.