I followed the example on http://bazalt-cms.com/ for the pagination but using $http.get instead of hard-coding a variable in the controller.
$http.get("data.json").success(function(data){
$scope.dataset = data;
}
I also moved the $scope.tableParams inside the $http.get
$http.get("data.json").success(function(data){
$scope.dataset = data;
$scope.tableParams = new ngTableParams({
...
}
});
and changed the data variable to $scope.dataset
total: $scope.dataset.length, // length of data
getData: function($defer, params) {
$defer.resolve($scope.dataset.slice((params.page() - 1) * params.count(), params.page() * params.count()));}
Everything works fine besides the pagination is now not working See Plnkr here
I've been working with ng-table for a while. When I tried using variable names other than $data or data, it doesn't seem to work. So I suggest you should stick to using $data or data instead of any other variable names like dataset.
Here's a working Plunker.
UPDATE :
Looks like I missed to see what was really wrong in the OP's question. As Tyler Collier and yunus kala mentioned in the comments, you just have to use $data like <tr ng-repeat="user in $data"> instead of <tr ng-repeat="user in dataset">. And it doesn't matter if you use data or dataset in your controller code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With