angularJS学习之路(十一)---ng-show和ng-hide

ng-show 和 ng-hide 根据表达式的值来显示或者隐藏HTML元素

ng-show   false   被隐藏

ng-hide true 被隐藏

<!DOCTYPE html>
<html ng-app="myApp">

	<head>
		<meta charset="utf-8">
		<title></title>
	</head>

	<body>

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

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

		<script type="text/javascript" src="../js/angular.min.js"></script>
		<script>
			var app = angular.module("myApp", []);
		</script>
	</body>

</html>

另外注意判断符号是    ===

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券