aftab
aftab

Reputation: 545

How can i disabled selection based on ng-model?

I want to disabled Proxy input field for selection till Attestor is selected , Currently both fields are readOnly, if attestor is not selected user should not be able to select Proxy. I am new to angularJS please help how we can implement this logic using ng-model.

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>

Upvotes: 0

Views: 22

Answers (1)

Kevin F
Kevin F

Reputation: 2885

You can use the 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"/>

Changing:

ng-disabled="!attestorDTO.attestorWorker"

to the condition that you want it to be disabled

Upvotes: 1

Related Questions