I have a select
list created with ng-repeat
and not ng-options
. The issue I have is that there is an extra blank list item that disappears as soon as the user change the value.
The answer to AngularJS - extra blank option added using ng-repeat in select tag mentions that the selected item should be initialized to avoid that issue. I did it but I still have a blank entry.
HTML:
<select ng-model="selectedLanguage">
<option ng-repeat="language in languages" value="{{language}}" ng-selected="selectedLanguage == language">{{language.name}}</option>
</select>
<h2>{{selectedLanguage}}</h2>
Controller:
app.controller('Ctrl', function($scope) {
$scope.languages = [{ name: "English", key: 'en' }, { name: "French", key: 'fr'}];
$scope.selectedLanguage = $scope.languages[0];
});
The Plunker