Is it possible to display JSON data in AngularJS using ng-repeat? I am trying to print only a specific part of the JSON data "data": [{"y":"23","x": "12"}], but nothing appears on the HTML page.
Try out the Demo here: http://plnkr.co/edit/zy1C2z39dXuuHDx8eqxK?p=preview
Here is the JSON Data:
{"series": [{"meter": "instance", "data": [{"y": 1.0, "x": "2015-07-21T14:21:33"}, {"y": 1.0, "x": "2015-07-22T14:21:34"}, {"y": 1.0, "x": "2015-07-23T14:21:34"}, {"y": 1.0, "x": "2015-07-24T14:23:39"}, {"y": 1.0, "x": "2015-07-25T14:23:39"}, {"y": 1.0, "x": "2015-07-26T02:43:39"}, {"y": 1.0, "x": "2015-07-27T14:24:33"}], "name": "demo", "unit": "instance"}], "settings": {}}
Using AngularJS
app.controller('ceilometerCtrl', function($scope, $http) {
$http.get("http://192.168.206.133:8080/admin/metering")
.success(function(response) {
$scope.metrics=response.series[0].data;
});
});
HTML Structure
<div ng-controller="ceilometerCtrl">
<div ng-repeat="metric in metrics">
Metric: {{metric.x}}
</div>
</div>
The Result: nothing is displayed on the page
Metric:
Metric:
Metric:
Metric:
Metric:
Metric:
Metric: