0

I'm populating an HTML select element with options loaded from an external datasource. This is working fine but I would like to have a default "dummy" value at the top. Eg. "--Select something--". How can this be achieved?

<select ng-Model="selectedModel" ng-options="model as model.Model__c for model in vehicleModels"></select>
Nielsm
  • 289
  • 1
  • 5
  • 18
  • Have a look at [http://stackoverflow.com/questions/14706986/empty-first-element-in-dropdown-list](http://stackoverflow.com/questions/14706986/empty-first-element-in-dropdown-list) – Gruff Bunny Aug 06 '15 at 08:50
  • Thank you. I'd seen that already but it just shows me a blank option... My label is never shown. – Nielsm Aug 06 '15 at 08:59

1 Answers1

1

you can use an ng-init as given below.

<select ng-init="selectedModel=vehicleModels[0]" ng-Model="selectedModel" ng-options="model as model.Model__c for model in vehicleModels"></select>

and have your dummy item as the first element in the vehicleModels array

Divya MV
  • 2,021
  • 3
  • 31
  • 55