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

2019-07-08 16:36:43 浏览数 (1)

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

ng-show   false   被隐藏

ng-hide true 被隐藏

代码语言:javascript复制
<!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 人点赞