Rajeev
Rajeev

Reputation: 46929

Angular directive to enable textbox

In the following if checkbox is clicked the readonly attribute from the textbox must be removed and on unclicking git should be added.Can this be done by angular directive

<div class="radio"> 
     <label>
       <input type="radio">Project</label>
       <input type="text" name="project" id="project" readonly/>
</div>

Upvotes: 1

Views: 220

Answers (2)

Daniel Cottone
Daniel Cottone

Reputation: 4480

You can just use the built-in directive ngReadonly:

<input type="checkbox" ng-model="readonly">Project</label>
<input type="text" name="project" id="project" value="" placeholder="Project" ng-readonly="!readonly"/>

Here's a working plunkr.

Upvotes: 2

nada
nada

Reputation: 972

Take a look on https://docs.angularjs.org/api/ng/directive/ngReadonly:

<label>Check me to make text readonly: <input type="checkbox" ng-model="checked"></label><br/>
<input type="text" ng-readonly="checked" value="I'm Angular" aria-label="Readonly field" />

Upvotes: 1

Related Questions