我正在检索无序列表并绑定到此处的下拉菜单,但在实例化时我希望能够在下拉列表中选择第0个项目。 ng-init="selectedTreatment=treatments[0]"
不起作用,因为列表在视图中被重新排序。角度下拉,按索引选择
<select ng-model="selectedTreatment"
ng-options="option.TreatmentName for option in (treatments | orderBy : 'TreatmentName')">
</select>
有没有一种方法可以做到这一点?
由于数据使用视图上的orderBy过滤器重新排序。数据中的第0项不是下拉菜单中的第0项。所以这是行不通的。 – gunwin