Created
July 10, 2014 06:36
-
-
Save ekancepts/62ef8662d843bcef0f09 to your computer and use it in GitHub Desktop.
ngtable pagination
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* js controller */ | |
this.updateTableParams = function (data) { | |
$scope.colorsTableParams = new ngTableParams({ | |
page: 1, | |
count: 10 | |
}, { | |
total: data.length, | |
getData: function($defer, params) { | |
$defer.resolve(data.slice((params.page() - 1) * params.count(), params.page() * params.count())); | |
} | |
}); | |
}; | |
$scope.color = {}; | |
$scope.colors = []; | |
this.updateTableParams($scope.colors); | |
$http.get('vehicle-colors').success(function (data){ | |
console.log(data); | |
$scope.colors = data; | |
this.updateTableParams(data); | |
}.bind(this)); | |
/* view */ | |
<div id="color-list"> | |
<h2>Vehicle Colors</h2> | |
<p><strong>Page:</strong> {{colorstableParams.page()}}</p> | |
<p><strong>Count per page:</strong> {{colorstableParams.count()}}</p> | |
<table ng-table="colorsTableParams" class="uk-table uk-width-1-1 uk-text-center"> | |
<tr ng-repeat="color in colors"> | |
<!-- <td data-title="'ID'">{{color.id}}</td>--> | |
<td data-title="'Name'">{{color.caption}}</td> | |
<td data-title="'Manufacturer'">{{color.vmo_caption}}</td> | |
<!-- <td data-title="''">{{color.image}}</td>--> | |
</tr> | |
</table> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment