I'm retrieving some data from a rest service and use it to populate the options in a select with AngularJS.
If the user opens the select after the data has been retrieved, there is no problem.
If the user opens the select before the data is retrieved, and keeps it opened until the options are populated, then chrome doesn't resize the list of options and just shows a scrollbar whith height one line. This is unconfortable and misleading to the user.
Is there some way to fix this in Chrome? I realize that I could keep the select disabled or hidden until I populate the options, but I want to know if there is some other alternative.
Html (the button simulates the call to a rest service):
<div ng-controller="MyCtrl">
<button type="button" ng-click="clickButton()">Add options
</button>
<select ng-model="value" style="width: 200px;"
ng-options="o.id as o.label for o in list"
><option value=""></option></select>
{{value}}
</div>
Javascript:
function MyCtrl($scope, $timeout) {
$scope.list = [];
function addToList() {
$scope.list = [{
"id" : 1,
"label" : "One"
}, {
"id" : 2,
"label" : "Two"
}, {
"id" : 3,
"label" : "Three"
}
];
}
$scope.clickButton = function() {
$timeout(function() {
addToList();
}, 5000);
};
}
In jsFiddle: http://jsfiddle.net/PabloMG/u3fz9be0/