I am trying to get name of json object (bdev0, and bdev1 in this case) from my dataset.
So far I have tried ng-options with no success. What I am trying to achieve in the following code is just to retrieve the name of json object. So far all the examples I have tried did not work for my case.
Code:
var myApp = angular.module('myApp', []);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
function MyCtrl($scope) {
$scope.data = [{
"Block_Devices": {
"bdev0": {
"Backend_Device_Path": "/dev/ram1",
"Capacity": "16777216",
"Bytes_Written": 1577,
"timestamp": "4365093970",
"IO_Operations": 17757,
"Guest_Device_Name": "vdb",
"Bytes_Read": 17793,
"Guest_IP_Address": "192.168.26.88"
},
"bdev1": {
"Backend_Device_Path": "/dev/ram2",
"Capacity": "16777216",
"Bytes_Written": 1975,
"timestamp": "9365093970",
"IO_Operations": 21380,
"Guest_Device_Name": "vdb",
"Bytes_Read": 20424,
"Guest_IP_Address": "192.168.26.100"
}
},
"Number of Devices": 2
}]
}
HTML
<div ng-controller="MyCtrl">
<select name="Block_Devices" ng-model="selectedDevice" ng-options="value.Block_Devices for value in data">
<option value="">Please Select Device</option>
</select>
</div>
Selected Device = {{selectedDevice}}