I am facing an issue with a dropdown that utilizes ng-options in Angular. There is a default option selected with an empty value, indicated by the "selected" attribute and matching the model's value.
Whenever I add a new element to the ng-options list, even if it does not have an empty value, it automatically becomes selected if the model still has an empty value (which points to the default empty option). The model's value remains empty, but the dropdown displays the newly added option as selected. I even tried setting the default option value to " " instead of just "", but the behavior stays the same.
Is there a way to prevent newly added options from being automatically selected?
<select class="form-control section" ng-model="action.prop">
<option value="" disabled selected>Select Property</option>
<option ng-repeat="prop in tr.props| orderBy:prop.name"
value="{{prop.name}}"> {{prop.name}} </option>
</select>