Home > Web Front-end > JS Tutorial > body text

AngularJS ng-show directive

黄舟
Release: 2017-02-16 13:35:17
Original
1182 people have browsed it

1. Problem background

The ng-show instruction of AngularJS, when the value is true, the HTML element is displayed; when the value is false, the HTML element is hidden


2. Implementation source code

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>AngularJS之ng-show指令</title>
		<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
	</head>
	<body>
		<p ng-app="" ng-init="flag=true">
			<button ng-show="flag">查询</button><br>
			<input type="checkbox" ng-model="flag" />老鼠<br>
			<input type="radio" ng-show="!flag" />猫<br>
			<label>{{flag}}</label>
		</p>
	</body>
</html>
Copy after login


3. Implement the source code


(1) Check the check box

Check the check box, the button will be displayed, and the radio button will be hidden

AngularJS ng-show directive

(2) Uncheck the check box

Uncheck the check box, the button is hidden, and the radio button is displayed

AngularJS ng-show directive

## The above is the content of the ng-show directive of AngularJS. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template