|
36 | 36 | module.directive('dirPaginate', ['$compile', '$parse', '$timeout', 'paginationService', function($compile, $parse, $timeout, paginationService) { |
37 | 37 | return { |
38 | 38 | terminal: true, |
39 | | - compile: function(element, attrs){ |
| 39 | + compile: function dirPaginationCompileFn(element, attrs){ |
40 | 40 | attrs.$set('ngRepeat', attrs.dirPaginate); // Add ng-repeat to the dom element |
41 | 41 | element.removeAttr(attrs.$attr.dirPaginate); // Remove the dir-paginate attribute to prevent infinite recursion of compilation |
42 | 42 |
|
|
51 | 51 | var itemsPerPageFilterRemoved = match[2].replace(filterPattern, ''); |
52 | 52 | var collectionGetter = $parse(itemsPerPageFilterRemoved); |
53 | 53 |
|
54 | | - return function(scope, element, attrs){ |
| 54 | + return function dirPaginationLinkFn(scope, element, attrs){ |
55 | 55 | var paginationId; |
56 | 56 | var compiled = $compile(element); // we manually compile the element again, as we have now swapped dir-paginate for an ng-repeat |
57 | 57 |
|
|
92 | 92 | compiled(scope); |
93 | 93 | }; |
94 | 94 | } |
95 | | - }; |
| 95 | + }; |
96 | 96 | }]); |
97 | 97 |
|
98 | 98 | module.directive('dirPaginationControls', ['paginationService', function(paginationService) { |
|
204 | 204 |
|
205 | 205 | scope.$watch(function() { |
206 | 206 | return paginationService.getCurrentPage(paginationId); |
207 | | - }, function(currentPage) { |
208 | | - goToPage(currentPage); |
| 207 | + }, function(currentPage, previousPage) { |
| 208 | + if (currentPage != previousPage) { |
| 209 | + goToPage(currentPage); |
| 210 | + } |
209 | 211 | }); |
210 | 212 |
|
211 | 213 | scope.setCurrent = function(num) { |
|
272 | 274 | module.service('paginationService', function() { |
273 | 275 | var instances = {}; |
274 | 276 | var lastRegisteredInstance; |
275 | | - this.paginationDirectiveInitialized = false; |
276 | 277 |
|
277 | 278 | this.registerInstance = function(instanceId) { |
278 | 279 | if (typeof instances[instanceId] === 'undefined') { |
|
0 commit comments