Angularjs Examples

AJS Examples


AngularJS ng-ReadOnly Directive

The AngularJS ng-readonly directive is used to make DOM elements readonly.It traverses all DOM elemets with the readonly property and makes the element readonly.

Syntax

<input type="text" ng-readonly="checked"/>

AngularJS ng-ReadOnly Directive Example

<html>
<head>
<title>My first AngularJS ng-readonly Directive code</title>
<Script SRC="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js">
</Script>
<Script>
function appController($scope) {
    $scope.firstName = "Jimi";
    $scope.lastName = "Scotts";
    $scope.truefalse = "false";
}
</Script>
</head>
<body>
<div ng-app ng-controller="appController">
    <p>First Name:
        <input ng-model="firstName" ng-readonly="true"/>
    </p>
    <p>Last Name:
        <input ng-model="lastName" ng-readonly="{{truefalse}}"/>
    </p>
</div>

</body>
</html>
See Live Example