Anijit Sau
Anijit Sau

Reputation: 575

How to disable a <select> <option> on change/select of an item of another <select><option> using Angular JS

I have two <select> <option> like

 <select name="fm" id="fm" class="form-control" >
    <option value="01" >All</option>
    <option value="01">01</option>
    <option value="02">02</option>
    <option value="03">03</option>
</select>

<select name="fq" id="fq" class="form-control" ng-disabled="MonthVal">
   <option value="Q1">Q1</option>
   <option value="Q2">Q2</option>
   <option value="Q3">Q3</option>
   <option value="Q4">Q4</option>
</select>

I want to disable the fm totally on change/select of any item in fq and vice-versa using Angular Js 1.5

Upvotes: 0

Views: 582

Answers (1)

devqon
devqon

Reputation: 13997

You can just disable the selects by checking if the other select has a value selected. You can do that by using ng-model:

<select name="fm" id="fm" class="form-control"
        ng-model="fm"
        ng-disabled="fq">
    <!-- // -->
</select>

<select name="fq" id="fq" class="form-control"
        ng-model="fq"
        ng-disabled="fm">
    <!-- // -->
</select>

Upvotes: 1

Related Questions