By default angular uses an empty value if nothing has been selected in a <select>
. How can I change this to a text that says Please select one
?
Default text in Angular select
Asked Answered
You didnt provide any code so I can't give an example relative to your code, but try adding an option element, e.g.
<select ng-model="item" ng-options="item.category for item in items"
ng-change="doSomething()">
<option value="">Please select one</option>
</select>
To add: Having value="" is important. It won't work if you just omit the value attribute. –
Compo
Via the ng-selected
attribute:
<select>
<option>Hello!</option>
<option ng-selected="selected">Please select one</option>
<option>Another option</option>
</select>
Check out the reference: https://docs.angularjs.org/api/ng/directive/ngSelected
© 2022 - 2024 — McMap. All rights reserved.