From df26c098fd067552b30f90154453d17c711af64c Mon Sep 17 00:00:00 2001 From: Rhys Brett-bowen Date: Mon, 18 Nov 2013 10:02:55 -0500 Subject: [PATCH] fix(ngRepeat): allow multiline expressions allow and pass through new line characters when checking passed in expression Closes #5000 --- src/ng/directive/ngRepeat.js | 2 +- test/ng/directive/ngRepeatSpec.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ng/directive/ngRepeat.js b/src/ng/directive/ngRepeat.js index 86874a418e7f..0a2673ffdb6b 100644 --- a/src/ng/directive/ngRepeat.js +++ b/src/ng/directive/ngRepeat.js @@ -203,7 +203,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) { $$tlb: true, link: function($scope, $element, $attr, ctrl, $transclude){ var expression = $attr.ngRepeat; - var match = expression.match(/^\s*(.+)\s+in\s+(.*?)\s*(\s+track\s+by\s+(.+)\s*)?$/), + var match = expression.match(/^\s*(.+)\s+in\s+([\r\n\s\S]*?)\s*(\s+track\s+by\s+(.+)\s*)?$/), trackByExp, trackByExpGetter, trackByIdExpFn, trackByIdArrayFn, trackByIdObjFn, lhs, rhs, valueIdentifier, keyIdentifier, hashFnLocals = {$id: hashKey}; diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js index bdc0b8f5b3b3..2d70d4a4d447 100644 --- a/test/ng/directive/ngRepeatSpec.js +++ b/test/ng/directive/ngRepeatSpec.js @@ -177,6 +177,22 @@ describe('ngRepeat', function() { }); + it('should allow expressions over multiple lines', function() { + scope.isTrue = function() { + return true; + }; + element = $compile( + '')(scope); + scope.items = [{name: 'igor'}]; + scope.$digest(); + + expect(element.find('li').text()).toBe('igor'); + }); + + it('should track using provided function when a filter is present', function() { scope.newArray = function (items) { var newArray = [];