I am currently fetching data from an API and populating a table. I need to reload the table every 1 second, so I attempted using $timeout but encountered an error that says -
$scope.tableParams.reload();//TypeError: Cannot read property 'reload' of undefined
Here is the code snippet:
<div align="center">
<div ng-app="myApp" ng-controller="customersCtrl">
<table ng-table="tableParams">
<tr>
<td>device id</td>
<td>device unique id</td>
<td>access status</td>
<td>current time</td>
</tr>
<tr>
<td>{{ access.id }}</td>
<td>{{ access.devid }}</td>
<td><img ng-src="{{statusValues[access.status]}}" /></td>
<td>{{ access.CurrentTime }}</td>
</tr>
</table>
</div>
</div>
<script type="text/javascript">
var app = angular.module('myApp', []);
app.controller('customersCtrl', function ($scope, $http, $timeout) {
$http.get("http://example.com/get")
$scope.reloadTable = function () {
$timeout(function () {
$scope.tableParams.settings().$scope = $scope;
$scope.tableParams.reload();
$scope.reloadTable();
}, 1000)
};
$scope.reloadTable();
});
</script>