I am having problem with setting default for my select list. Any help on this would be appreciated. I looked at the other similar posts but the solutions are not seem to be working in my case.
I populate $scope.series in the controller. and then the drop down seems to be populating as well but it is not setting the default value.
<select name="repeatSelect" id="repeatSelect"
ng-init="selectedItem = series[0].code"
ng-model="selectedItem"
ng-options="serie.name for serie in series track by serie.code"
ng-change="update()"></select>
here is the json:
[
{
"code": "code1",
"name": "name 1",
},
{
"code": "code2",
"name": "name 2",
}
]
Following is the controller
angular.module("myApp", [])
.controller('myController', function ($scope, dataService) {
dataService.getSeries(function (response) {
$scope.series = response.data;
console.log(response.data);
})});
Where dataService is the service to get json file from $http get.