I am using angularjs in a project and in which I am using ng-options for generating .
Initially when the pages reload and no option element is selected the html gene
You can forgo using the ng-options
and use ng-repeat
instead and make the first option blank. See example below.
<select size="3" ng-model="item">
<option value="?" selected="selected"></option>
<option ng-repeat="s in itemlist" value="{{s.value}}">{{s.name}}</option>
</select>
I had same problem and after a lot of googling,I understood the main issue was related to my angular version, if you use Angular 1.6.x, just use the ng-value directive and it will work as expected.
also I set an initial value in my controller, like this :
$scope.item = 0;