Skip to content

Commit 955d882

Browse files
1 parent e961a9c commit 955d882

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/directives/pagination/dirPagination.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
// regex taken directly from https://github.com/angular/angular.js/blob/v1.4.x/src/ng/directive/ngRepeat.js#L339
5757
var match = expression.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);
5858

59-
var filterPattern = /\|\s*itemsPerPage\s*:\s*(.*\(\s*\w*\)|([^\)]*?(?=as))|[^\)]*)/;
59+
var filterPattern = /\|\s*itemsPerPage\s*:\s*(.*\(\s*\w*\)|([^\)]*?(?=\s+as\s+))|[^\)]*)/;
6060
if (match[2].match(filterPattern) === null) {
6161
throw 'pagination directive: the \'itemsPerPage\' filter must be set.';
6262
}

src/directives/pagination/dirPagination.spec.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,18 @@ describe('dirPagination directive', function() {
287287
expect(getListItems().length).toEqual(10);
288288
});
289289

290+
// see https://github.com/michaelbromley/angularUtils/issues/241
291+
// the actual issue was caused by the work "sharedTasksFilters", which was
292+
// being matched by the part of the regex that looks for "as" alias syntax.
293+
it('should allow deeply nested, long-winded object for itemsPerPage', function() {
294+
function compile() {
295+
$scope.eventsCtrl = { eventsFilters: { sharedTasksFilters: { eventsPerPage: 10 } } };
296+
compileElement(myCollection, 5, 1, "item in collection | itemsPerPage:eventsCtrl.eventsFilters.sharedTasksFilters.eventsPerPage");
297+
}
298+
expect(compile).not.toThrow();
299+
expect(getListItems().length).toEqual(10);
300+
});
301+
290302

291303
it('should allow track by syntax 1', function() {
292304
function compile() {

0 commit comments

Comments
 (0)