This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
ngOptions in Angular 1.4 broke <select> placeholder values using ng-if #12190
Closed
Description
In Angular, you can specify a placeholder value for a <select>
by doing something like so:
<select ng-options="o.name for o in options" ng-model="model">
<option value="">Please choose</option>
</select>
This still works, however even when you choose an option in the list, the 'Please choose' placeholder still shows. To get around this, you could use an ng-if
on the placeholder <option>
to hide the option if a model value was selected, like so:
<select ng-options="o.name for o in options" ng-model="model">
<option ng-if="!model" value="">Please choose</option>
</select>
However this no longer works in Angular 1.4, the placeholder no longer shows and the entire list is cleared if you choose one of the other options.
I have created a plunkr to demonstrate this, see here: http://plnkr.co/edit/NDXZLkGavwBU3Qg5YAtT