Tutorials References Menu

AngularJS ng-disabled Directive


Example

Disable / enable the input field:

Disable form fields: <input type="checkbox" ng-model="all">
<br>
<input type="text" ng-disabled="all">
<input type="radio" ng-disabled="all">
<select ng-disabled="all">
<option>Female</option>
<option>Male</option>
</select>
Try it Yourself »

Definition and Usage

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

The form field will be disabled if the expression inside the ng-disabled attribute returns true.

The ng-disabled directive is necessary to be able to shift the value between true and false. In HTML, you cannot set the disabled attribute to false (the presence of the disabled attribute makes the element disabled, regardless of its value).


Syntax

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

Supported by <input>, <select>, and <textarea> elements.


Parameter Values

Value Description
expression An expression that will set the element's disabled attribute if it returns true.