<select ng-model="dayOfMonth">
<option value="" label="Select day"></option>
<option ng-selected="parseInt(dayOfMonth) === parseInt(day+1)" ng-repeat="day in getTotalDays() track by $index" value="{{$index+1}}>{{$index+1 | ordinal}} of the month</option>
</select>
My dayOfMonth
ng-model is set to 12, but the default value selection based on dayOfMonth
is consistently choosing the last index instead.
The getTotalDays
function, shown below, simply generates an array containing 28 items.
$scope.getTotalDays = function(){
return new Array(28);
}