AngularJS ng-readonlyDirective

AngularJS 参考手册AngularJS Reference Manual


AngularJS Example

Set the input field to read-only:

Readonly: <input type="checkbox" ng-model="all">
<br>
<input type="text" ng-readonly="all">

Try it Yourself »

Definition and Usage

ng-readonlyThis directive is used to set the readonly attribute of form fields (input or textarea).

Ifng-readonlythe expression in the attribute returns true, the form field is read-only.


Syntax

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

The <input> and <textarea> elements support this directive.


Parameter Value

Value Description
expression If the expression returns true, the form field is read-only.

AngularJS 参考手册AngularJS Reference Manual

Other Extensions