Skip to content

Commit 057eed2

Browse files
committed
Fix michaelbromley#281 onPageChange callback with oldPageNumber
1 parent fee46ae commit 057eed2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/directives/pagination/dirPagination.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,13 +309,19 @@
309309

310310
function goToPage(num) {
311311
if (paginationService.isRegistered(paginationId) && isValidPageNumber(num)) {
312+
var oldPageNumber = scope.pagination.current;
313+
312314
scope.pages = generatePagesArray(num, paginationService.getCollectionLength(paginationId), paginationService.getItemsPerPage(paginationId), paginationRange);
313315
scope.pagination.current = num;
314316
updateRangeValues();
315317

316-
// if a callback has been set, then call it with the page number as an argument
318+
// if a callback has been set, then call it with the page number as the first argument
319+
// and the previous page number as a second argument
317320
if (scope.onPageChange) {
318-
scope.onPageChange({ newPageNumber : num });
321+
scope.onPageChange({
322+
newPageNumber : num,
323+
oldPageNumber : oldPageNumber
324+
});
319325
}
320326
}
321327
}

0 commit comments

Comments
 (0)