angularjs ng-readonly directive

angularjs example

Set the input box to read-only:

<! Doctype html>
<meta charset="utf-8">
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<body ng-app="">
Tick ​​the checkbox to set the input box to read-only:<input type="checkbox" ng-model="all"><br>
<input type="text" ng-readonly="all">

Definition and usage

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

If the expression of the ng-readonly property returns true, the form field is read-only.


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

The<input><textarea>element supports the directive.

Parameter value

value description
expression If the expression returns true, the form field is read-only.

  • Previous yii2 Controller Ajax operation example
  • Next Powerful Bootstrap effect display (2)