Skip to content

Commit

Permalink
fix(ngRepeat): allow multiline expressions
Browse files Browse the repository at this point in the history
allow and pass through new line characters when checking passed in expression

Closes angular#5000
  • Loading branch information
rhysbrettbowen authored and jamesdaily committed Jan 27, 2014
1 parent 7ac5ccf commit df26c09
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ng/directive/ngRepeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
16 changes: 16 additions & 0 deletions test/ng/directive/ngRepeatSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,22 @@ describe('ngRepeat', function() {
});


it('should allow expressions over multiple lines', function() {
scope.isTrue = function() {
return true;
};
element = $compile(
'<ul>' +
'<li ng-repeat="item in items\n' +
'| filter:isTrue">{{item.name}}</li>' +
'</ul>')(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 = [];
Expand Down

0 comments on commit df26c09

Please sign in to comment.