ng-options 的实现

implementation of ng-options

我想在下面显示 A 和 B 作为我的选项列表

$scope.devices={
    "A": {
        "status": 3,
        "event": "Door was opened",
        "name": "xxxxxx ",
        "latlng": "xxxxx"
    },

    "B": {
        "status": 4,
        "event": "kitchen was opened",
        "name": "xxxxx ",
        "latlng": "xxxxx"
}
}

我正在尝试这样

<select ng-change="selected(prop)" style="color:black;" ng-model="prop" ng-options="item as item for item in devices">
                            <option value="">-- choose an option --</option>
                        </select>

你可以这样,

<label for="reason">Device</label>
   <select ng-change="selected(Device)" ng-model="Device" ng-options="key as key for (key , value) in devices"></select>
</div>

DEMO