【发布时间】:2014-02-27 02:15:05
【问题描述】:
我的下拉 html 如下所示:
<select name="originType" class="form-control"
ng-model="myLocationType"
ng-options="type.Key as type.Value for type in allLocationTypes"
required></select>
这可以很好地填充下拉列表。但是,当我加载页面并用模型数据填充它时,应该选择的值永远不会是。下拉菜单始终使用默认(空白)值。我对不是键/值对的下拉列表没有任何问题。例如:
<select name="shipId" class="form-control"
ng-model="WageAgreement.ShipId"
ng-options="shipId for shipId in manufacturers"
required></select>
【问题讨论】:
-
Angular 总是在选择中提供默认选项。当模型未定义时显示。如果您希望默认选项为其他内容,请为选择模型分配一个值。
标签: angularjs html-select