|
60 | 60 | var itemsPerPageFilterRemoved = match[2].replace(filterPattern, ''); |
61 | 61 | var collectionGetter = $parse(itemsPerPageFilterRemoved); |
62 | 62 |
|
| 63 | + var paginationId = tAttrs.paginationId || '__default'; |
| 64 | + paginationService.registerInstance(paginationId); |
| 65 | + |
63 | 66 | return function dirPaginationLinkFn(scope, element, attrs){ |
64 | | - var paginationId; |
65 | 67 | var compiled = $compile(element, false, 5000); // we manually compile the element again, as we have now added ng-repeat. Priority less than 5000 prevents infinite recursion of compiling dirPaginate |
66 | 68 |
|
67 | | - paginationId = attrs.paginationId || '__default'; |
68 | | - paginationService.registerInstance(paginationId); |
69 | | - |
70 | 69 | var currentPageGetter; |
71 | 70 | if (attrs.currentPage) { |
72 | 71 | currentPageGetter = $parse(attrs.currentPage); |
|
238 | 237 | } |
239 | 238 |
|
240 | 239 | function generatePagination() { |
241 | | - scope.pages = generatePagesArray(1, paginationService.getCollectionLength(paginationId), paginationService.getItemsPerPage(paginationId), paginationRange); |
242 | | - scope.pagination.current = parseInt(paginationService.getCurrentPage(paginationId)); |
| 240 | + var page = parseInt(paginationService.getCurrentPage(paginationId)) || 1; |
| 241 | + |
| 242 | + scope.pages = generatePagesArray(page, paginationService.getCollectionLength(paginationId), paginationService.getItemsPerPage(paginationId), paginationRange); |
| 243 | + scope.pagination.current = page; |
243 | 244 | scope.pagination.last = scope.pages[scope.pages.length - 1]; |
244 | 245 | if (scope.pagination.last < scope.pagination.current) { |
245 | 246 | scope.setCurrent(scope.pagination.last); |
|
309 | 310 | instances[instanceId].currentPageParser.assign(instances[instanceId].context, val); |
310 | 311 | }; |
311 | 312 | this.getCurrentPage = function(instanceId) { |
312 | | - return instances[instanceId].currentPageParser(instances[instanceId].context); |
| 313 | + var parser = instances[instanceId].currentPageParser; |
| 314 | + return parser ? parser(instances[instanceId].context) : 1; |
313 | 315 | }; |
314 | 316 |
|
315 | 317 | this.setItemsPerPage = function(instanceId, val) { |
|
0 commit comments