Angular指令启用文本框

时间:2015-07-20 13:55:12

标签: javascript html angularjs angularjs-directive

在下面的if复选框中,必须删除文本框中的readonly属性,并且应该添加未删除的git。可以通过angular directive

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

2 个答案:

答案 0 :(得分:2)

您可以使用内置指令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.

答案 1 :(得分:1)

查看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" />