我有以下HTML标记:
<select id="selectDays" class="form-control" ng-model="selectedDays"
ng-options="value.id as value.name for value in searchDays" ng-change="selectChange()">
</select>
searchDays是$ scope中定义的json数组:
$scope.searchDays = [{ name: "30 Days", id: 30 }, { name: "60 Days", id: 60 }, { name: "90 Days", id: 90 }];
我希望选择第三个选项,即90天,我正在使用此代码,但它不起作用:
//select 90 Days
$scope.selectedDays = $scope.searchDays[2];
我错过了什么吗?
答案 0 :(得分:2)
指定id
属性:
$scope.selectedDays = $scope.searchDays[2].id