如何根据ng-model禁用选择?

时间:2015-06-18 19:59:00

标签: html angularjs

我想禁用代理输入字段以供选择,直到选中Attestor,目前这两个字段都是readOnly,如果未选择

main.html

 <div class="row">
    <div class="form-group col-md-6">
        <label for="attestorWorker" class="col-md-4">Attestor:</label>
        <div class="col-md-8">
            <input type="text" class="form-control" id="attestorWorker" required
                ng-model="attestorDTO.attestorWorker" name="attestorWorker"
                ng-click="openAttestorSearch()"  readonly="readonly"/>
        </div>
    </div>
</div>
 <div class="row">
    <div class="form-group col-md-6">
        <label for="proxyWorker" class="col-md-4">Proxy :</label>
        <div class="col-md-8">
            <input type="text" class="form-control" id="proxyWorker" required
                ng-model="attestorDTO.proxyWorker" name="proxyWorker"
                ng-click="openProxySearch()"  readonly="readonly"/>
        </div>
   </div>
</div>

1 个答案:

答案 0 :(得分:1)

您可以使用ng-disabled attribute

<input type="text" class="form-control" id="proxyWorker" required
                ng-model="attestorDTO.proxyWorker" name="proxyWorker"
                ng-click="openProxySearch()"  readonly="readonly"
                ng-disabled="!attestorDTO.attestorWorker"/>

更改:

ng-disabled="!attestorDTO.attestorWorker"

到你希望它被禁用的条件