Angular.js通过对象键上的ng-options进行跟踪

时间:2016-05-09 09:00:33

标签: javascript angularjs

考虑以下对象:

var orderedFlights = {
   "Airline 1": {},
   "Airline 2": {},
   "Airline 3": {}
}

使用ng-options是否可以在对象的键上track by

<select 
    class="form-control" 
    ng-change="flightNumber = airline[0]" 
    name="airline" 
    id="airline" 
    ng-model="airline" 
    ng-options="airline for (airline, flights) in orderedFlights track by airline">
</select>

1 个答案:

答案 0 :(得分:0)

试试这个

 ng-options="airline as airline for (airline, flights)  in orderedFlights track by airline">