AngularJS之ng-disabled指令

时间:2022-06-08 18:49:26

1、问题背景

     AngularJS中的ng-disabled指令绑定DOM,可以禁用HTML元素


2、实现源码

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

3、实现结果

(1)勾选复选框

‘  

(2)取消勾选复选框