Skip to content

Commit a5e1a86

Browse files
1 parent b2a5dd4 commit a5e1a86

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

‎src/directives/pagination/dirPagination.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,13 @@
260260
total: 1
261261
};
262262

263+
scope.$watch('maxSize', function(val) {
264+
if (val) {
265+
paginationRange = Math.max(scope.maxSize, 5);
266+
generatePagination();
267+
}
268+
});
269+
263270
scope.$watch(function() {
264271
if (paginationService.isRegistered(paginationId)) {
265272
return (paginationService.getCollectionLength(paginationId) + 1) * paginationService.getItemsPerPage(paginationId);

‎src/directives/pagination/dirPagination.spec.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,23 @@ describe('dirPagination directive', function() {
550550
expect(pageLinks).toEqual(['‹','1', '2', '3', '...', '10', '›']);
551551
});
552552

553+
it('should alter links array when value of max-size changes', function() {
554+
$scope.maxSize = 5;
555+
compileWithAttributes(' max-size="maxSize" ');
556+
557+
var pageLinks = getPageLinksArray();
558+
559+
expect(pageLinks).toEqual(['‹','1', '2', '3', '...', '10', '›']);
560+
561+
$scope.$apply(function() {
562+
$scope.maxSize = 9;
563+
});
564+
565+
pageLinks = getPageLinksArray();
566+
567+
expect(pageLinks).toEqual(['‹','1', '2', '3', '4', '5', '6', '7', '...', '10', '›']);
568+
});
569+
553570
it('should impose a minimum max-size of 5', function() {
554571
compileWithAttributes(' max-size="2" ');
555572

0 commit comments

Comments
 (0)