我选择了包含选项的列表:
<select ng-model="yr[$index]" ng-selected="year.id == 'I'" ng-options="year.id as year.id for year in years">
</select>
如何在选择列表中选择第一个元素,其中element是string? 我的代码是:
答案 0 :(得分:2)
您可以编写另一个名为currentYear
的变量,如下所示:
$scope.currentYear = $scope.years[0];
并选择以下内容:
<select ng-model="currentYear" ng-options="year.id disable when (year.id < yr[$index]) for year in years">
</select>
更新后
要显示该值,您可以将select添加如下:
<select ng-model="currentYear.value" ng-options="year.value as year.value for year in years">
</select>
答案 1 :(得分:1)
尝试使用:ng-init =“something = options [0]”