I am using api to get data into plain text from json data. I am not able to display the data in to the table using angularjs.
here is the sample json
{"success":true,"sensorsdata":{"id":1,"devid":"car1","status":"true","CurrentTime":"24-January-2017 03:54:PM"}}
here is my code
<body>
<div ng-app="myApp" ng-controller="customersCtrl">
<table>
<tr>
<td>{{ access.id }}</td>
<td>{{ access.devid }}</td>
<td>{{ access.status }}</td>
<td>{{ access.CurrentTime }}</td>
</tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get("url")
.then(function (response) { $scope.access = response.data;});
});
</script>
</body>
You should change response.data
to response.data.sensorsdata
.
app.controller('customersCtrl', function($scope, $http) {
$http.get("url")
.then(function (response) { $scope.access = response.data.sensorsdata; });
});
You have a key of sensorsdata
in response and you are accessing response.data
. Just change that.
Try below code.
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$http.get("url")
.then(function (response) { $scope.access = response.sensorsdata;});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.