0

Initially my dropdown has a blank option by default, I would like to change the text of this option. how can I do it?

<body ng-controller="controller">
  <span>Options: </span>
  <select ng-options="item as item.name for item in regions track by item.code" ng-model="select">
  </select>
</body>

http://plnkr.co/edit/jEbxk4swidVenhKqZAFP?p=preview

yavg
  • 2,761
  • 7
  • 45
  • 115
  • Possible duplicate of [Why does AngularJS include an empty option in select?](https://stackoverflow.com/questions/12654631/why-does-angularjs-include-an-empty-option-in-select) – Ben Kolya Mansley Jan 25 '18 at 22:21
  • @Claies sorry I updated the code.. – yavg Jan 25 '18 at 22:25
  • @Claies I just need the blank text of the first dropdown option to be changed to 'select an option please' – yavg Jan 25 '18 at 22:26
  • sorry I misread the question, you aren't trying to set a default value, you are trying to make it so that the "empty" value isn't blank, which makes the proposed answer correct. – Claies Jan 25 '18 at 22:27

1 Answers1

2
    <select ng-options="item as item.name for item in regions track by item.code" ng-model="select">
      <option value="">Text Goes Here</option>
    </select>

You can also hide that option once something's chosen by using

<option ng-if="!select" value="">Text Goes Here</option>
DavidX
  • 1,281
  • 11
  • 16