I'm using the very good table library Smart-table to display my data.
I am using a custom pagination template. I would however like to be able to set the page to the last one so I could see the last item added.
This is the pagination.html :
<nav ng-if="pages.length >= 2">
<ul class="pagination">
<li>
<a ng-click="selectPage(1)">First</a>
</li>
<li>
<a ng-click="selectPage(currentPage - 1)"><</a>
</li>
<li>
<a><page-select></page-select> of {{numPages}}</a>
</li>
<li>
<a ng-click="selectPage(currentPage + 1)">></a>
</li>
<li>
<a ng-click="selectPage(numPages)">Last</a>
</li>
</ul>
And this is the directive
angular.module('myApp')
.directive('pageSelect', function() {
return {
restrict: 'E',
template: '<input type="text" class="select-page" ng-model="inputPage" ng-change="selectPage(inputPage)">',
link: function(scope, element, attrs) {
scope.$watch('currentPage', function(c) {
scope.inputPage = c;
});
}
}
});