I have problem with empty option when i repeat through array. Here is code.
View:
<select ng-model="getseason" class="form-control">
<option ng-repeat="season in seasons" value="{{ season }}">
Season {{ season + '/' + seasonaddone(season) }}
</option>
</select>
Model:
$scope.getseason={};
$scope.seasons = [2014,2013,2012,2011,2010,2009,2008,2007,2006,2005];
$scope.getseason = $scope.seasons[0];
$scope.seasonaddone = function(season){
return ++season;
}
$scope.$watch('getseason',function(){
console.log($scope.getseason);
console.log(typeof $scope.getseason);
});
How can i remove empty option? I find many similiar problems, but i cant find solution for this.
Try to use ngOptions instead of ngRepeat
Try like this
<select ng-model="getseason" class="form-control" ng-options="season as 'Season '+ season + '/' + seasonaddone(season) for season in seasons">
</select>