AngularJS Basic ng disabled Instruction Detailed Explanation and Simple Example

  • 2021-07-06 10:08:37
  • OfStack

AngularJS ng-disabled Directive

AngularJS instance

Disable or enable input boxes:


<!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="">
 Click here to disable all form input fields :<input type="checkbox" ng-model="all"><br>
<br>

<input type="text" ng-disabled="all">
<input type="radio" ng-disabled="all">
<select ng-disabled="all">
 <option>Female</option>
 <option>Male</option> 
</select>

</body>
</html>

Definition and usage

The ng-disabled directive sets the disabled property of the form input field (input, select, or textarea).

If the expression in ng-disabled returns true, the form field is disabled.

Grammar

< input ng-disabled="expression" > < /input >

< input > , < select > , and < textarea > Element supports this directive.

Parameter value

描述
expression 如果表达式返回true,则设置为元素添加 disabled 属性。

The above is to sort out the basic knowledge of ng-disabled instructions, and continue to supplement relevant knowledge in the future.


Related articles: