AngularJS - extra blank option added using ng-repeat in select tag AngularJS - extra blank option added using ng-repeat in select tag angularjs angularjs

AngularJS - extra blank option added using ng-repeat in select tag


Any time you see <option value="?" selected="selected"></option> in the select, it means that your ng-model is set to a value that isn't in the ng-options. So, if you don't want the blank option, you need to make sure item is set to a value in your itemlist. This could be as easy as having the following in your controller:

$scope.item = $scope.itemlist[0];

This will give it an inital value, and then angular will update it for you thereafter.


simplest way to make sure that automatically added option by angular is hidden is ng-if directive.

<select ng-options="option.id as option.description for option in Options">    <option value="" ng-if="false"></option></select>