Issue : I have a value that is coming from backend and needs to be on the dropdown(It needs to be the default selected value). The dropdown has set of values including that value. But somehow even after specifying that value in the scoep, It is not showing up in the frontend. Here is the code.
HTML
<select class="bs-select form-control" ng-model="car.yearOfPurchase " id="year" name="year" required="">
<option ng-repeat="year in years" value="year">{{year}}</option>
</select>
JS
$scope.years = [];
for (var i = 2002; i <= parseInt(moment().format("YYYY")); i++) {
$scope.years.push(i.toString());
}
/*Value comign from backend. Mocked in this case.*/
$scope.car = {
yearOfPurchase : "2006"
};
$scope.year = $scope.car.yearOfPurchase;
Also, I have created a plunker for the same.
<option ng-repeat="year in years" value="{{year}}">{{year}}</option>