在<select>
输入中,我们可以添加禁用选项作为占位符:
<select>
<option value="" disabled selected>Select your option</option>
<option value="1">January</option>
...
</select>
但是我们如何在AngularJS构建的<select>
中添加禁用选项,其中ng-options
是从控制器提供的?
<select class="month" id="month"
ng-model="vm.month"
ng-options="m for m in vm.months">
</select>
答案 0 :(得分:5)
我很容易!谢谢HarishR。
<select class="month" id="month"
ng-model="vm.month"
ng-options="m for m in vm.months">
<option value="" disabled selected>Select your option</option>
</select>
我们甚至可以动态显示/隐藏占位符选项:
<select class="month" id="month"
ng-model="vm.month"
ng-options="m for m in vm.months">
<option value="" disabled selected ng-hide="vm.month">Select your option</option>
</select>