I have a select element that should be filled with some options that I need to retrieve from an API call, then set the first one as selected.
But Angular creates an empty option at first position and I don't know how to delete it.
Here's my code:
HTML
<select class="form-control" ng-model="selectedPositionFamily">
<option ng-repeat="pf in positionFamilies" ng-value="pf.uuid">{{pf.name}}</option>
</select>
Controller
function Controller($scope, PositionFamilyService) {
$scope.positionFamilies = [];
$scope.selectedPositionFamily = "";
initController();
function initController() {
PositionFamilyService.getAll({ 'sort' : 'order,asc' })
.then(function(data){
$scope.positionFamilies = data.content;
$scope.selectedPositionFamily = $scope.positionFamilies[0].uuid;
});
}
}