嘗試在select中根據id設置默認值。Angular:ng-select不顯示ng-selected值
我有一個對象location
其中<pre>{{location.routeId}}</pre>
打印一個id 819e41ef-0081-41e6-a415-2766dc16e8e4
<select ng-model="location.route">
<option value="" disabled>Choose Route</option>
<option ng-repeat="route in appData.Routes"
ng-selected="{{route.id == location.routeId}}"
value="{{route}}">
{{route.id}} : {{route.name}}
</option>
</select>
在appData.Routes
的route
有參數name
和id
,我想匹配route.id
與location.routeId
如果我檢查元素,對於其中一個選項,我可以看到ng-selected
爲true,但仍然未在UI中選擇它。
這裏是UI
沒有幫助。 –