mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
fix(ngRepeat): allow multiline expressions
allow and pass through new line characters when checking passed in expression Closes #5000
This commit is contained in:
parent
45af02de04
commit
cbb3ce2c30
2 changed files with 17 additions and 1 deletions
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -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 = [];
|
||||
|
|
|
|||
Loading…
Reference in a new issue