如果在下拉列表中未选择任何内容,则应取消该按钮。我怎样才能做到这一点?
<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>
答案 0 :(得分:1)
尝试使用按钮上的ng-disabled="!ak.action || ak.action.length == 0"
。
虽然select
将始终包含您选择的项目......
<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>