selected
代码无效,因为ng-model取决于ng-selected,如何将One
硬编码为此处的默认选择?
<div ng-app="myapp">
<fieldset ng-controller="FirstCtrl">
<select ng-model="selectedPerson">
<option selected value="1">One</option>
<option value="2">Two</option>
</select>
</fieldset>
</div>
答案 0 :(得分:1)
您可以删除&#34;已选择&#34;从你的角度来看
<div ng-app="myapp">
<fieldset ng-controller="FirstCtrl">
<select ng-model="selectedPerson">
<option value="1">One</option>
<option value="2">Two</option>
</select>
</fieldset>
</div>
在控制器内部,只需执行以下操作:
$scope.selectedPerson = '1';