Skip to content

Instantly share code, notes, and snippets.

@ekancepts
Created July 10, 2014 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ekancepts/62ef8662d843bcef0f09 to your computer and use it in GitHub Desktop.
Save ekancepts/62ef8662d843bcef0f09 to your computer and use it in GitHub Desktop.
ngtable pagination
/* 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