Skip to content

Commit

Permalink
Update to v0.3.0
Browse files Browse the repository at this point in the history
See release notes for details
  • Loading branch information
michaelbromley committed Oct 13, 2014
1 parent 471f966 commit 842d622
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angularUtils-pagination",
"version": "0.2.6",
"version": "0.3.0",
"homepage": "https://github.com/michaelbromley/angularUtils/tree/master/src/directives/pagination",
"authors": [
"Michael Bromley <michael@michaelbromley.co.uk>"
Expand Down
19 changes: 14 additions & 5 deletions dirPagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,20 @@
module.directive('dirPaginate', ['$compile', '$parse', '$timeout', 'paginationService', function($compile, $parse, $timeout, paginationService) {
return {
terminal: true,
compile: function dirPaginationCompileFn(element, attrs){
attrs.$set('ngRepeat', attrs.dirPaginate); // Add ng-repeat to the dom element
element.removeAttr(attrs.$attr.dirPaginate); // Remove the dir-paginate attribute to prevent infinite recursion of compilation
multiElement: true,
priority: 5000, // This setting is used in conjunction with the later call to $compile() to prevent infinite recursion of compilation
compile: function dirPaginationCompileFn(tElement, tAttrs){

// Add ng-repeat to the dom element
if (tElement[0].hasAttribute('dir-paginate-start') || tElement[0].hasAttribute('data-dir-paginate-start')) {
// using multiElement mode (dir-paginate-start, dir-paginate-end)
tAttrs.$set('ngRepeatStart', tAttrs.dirPaginate);
tElement.last().attr('ng-repeat-end', true);
} else {
tAttrs.$set('ngRepeat', tAttrs.dirPaginate);
}

var expression = attrs.dirPaginate;
var expression = tAttrs.dirPaginate;
// regex taken directly from https://github.com/angular/angular.js/blob/master/src/ng/directive/ngRepeat.js#L211
var match = expression.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);

Expand All @@ -53,7 +62,7 @@

return function dirPaginationLinkFn(scope, element, attrs){
var paginationId;
var compiled = $compile(element); // we manually compile the element again, as we have now swapped dir-paginate for an ng-repeat
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

paginationId = attrs.paginationId || '__default';
paginationService.registerInstance(paginationId);
Expand Down

0 comments on commit 842d622

Please sign in to comment.