I have this below select which won't show the default value when statuslist is read from the server through a http call in IE9. If statuslist values are set in the controller itself then default value show up fine.
<select id="status" class="form-control" ng-init="selectedStatus = statuslist[0]"
ng-model="selectedStatus"
ng-options="status for status in statuslist">
</select>
Default value is displayed in the dropdown if I do this
$scope.statuslist = [
"New",
"Management Review"
]
but not if the statuslist is from the server. I can see the list if I click the dropdown but not the default value.
Can someone please point at the obvious I am missing here?
ng-init
shouldn't be used there, because it will get evaluated as the html get rendered and at that timestatuslist
value was not getting loaded inside$scope
, so it will set asselectedStatus
asundefined
Better you should add this line
$scope.selectedStatus = $scope.statuslist[0]
right after after thestatuslist
gets loaded from the server.