I have a ui in which based on the selection of one drop down another dropdown should be disabled. Both these dropdowns are generated using ng-repeat . Below is the code sample
<tr data-ng-repeat="abc in xyz.divisionViewList" >
<select
data-ng-model="abc.selectedAppRole"
ng-init="abc.selectedAppRole =abc.selectedAdRole"
id="{{abc.applicationId}}_{{abc.divisionId}}" name="{{abc.selectedAppRole}}">
<option value="null">Select/Deselect a role</option>
<option data-ng-repeat="roleDetail in abc.roleDetails" data-ng-selected="{{abc.adRole == abc.selectedAdRole}}"
value="{{abc.adRole}}"> {{abc.roleDesc}} </option>
</select>
</tr>
As this is a dynamic generated drop downs based on ng- repeat, i want to put validations based on selection on one drop down. Please let me know how can i put this validation so that i can disable and enable any dropdown based on selection of the other. I am really stuck on this.
Use
ng-disabled
and use model value of one of the dropdowns to disable/enable the other.Example app:
Example template code:
DropdownB will be enabled when DropdownA has option 2 selected. DropdownC will be enabled when DropdownB has option 3 selected. Of course this is only basic example, the code is not perfect, but demonstrates the idea.
I've created working example in this JSFiddle.
More information about ng-disabled can be found in this doc.