0

The button should be disabeled, when nothing is selected at the dropdown. How can I achieve this?

<select size='1' id="action" ng-model="ak.action">
    <option value='1'>RED</option>
    <option value='2'>BLUE</option>
</select>

<div>
    <button type="button" ng-Click="ak.save()" >SAVE</button>
</div>
georgeawg
  • 48,608
  • 13
  • 72
  • 95
LuMi
  • 41
  • 2
  • 6

1 Answers1

0

Try using ng-disabled="!ak.action || ak.action.length == 0" on the button. Although the select will always have a selected item in your case...

<select size='1' id="action" ng-model="ak.action">
        <option value='1'>RED</option>
        <option value='2'>BLUE</option>
</select>

<div>
    <button ng-disabled="!ak.action || ak.action.length == 0" type="button" ng-click="ak.save()" >SAVE</button>
</div>
daan.desmedt
  • 3,752
  • 1
  • 19
  • 33