English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

AngularJS ng-readonly Directive

AngularJS Reference Manual

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script>
</head>
<body ng-app="">
Check the checkbox to set the input box to read-only:<input type="checkbox" ng-model="all"><br>
<br>
<input type="text" ng-readonly="all">
</body>
</html>
Test and See ‹/›

Definition and Usage

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

If ng-readonly If the expression of 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

ValueDescription
expressionIf the expression returns true, the form field is read-only.

AngularJS Reference Manual