mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-05 05:34:43 +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,
|
$$tlb: true,
|
||||||
link: function($scope, $element, $attr, ctrl, $transclude){
|
link: function($scope, $element, $attr, ctrl, $transclude){
|
||||||
var expression = $attr.ngRepeat;
|
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,
|
trackByExp, trackByExpGetter, trackByIdExpFn, trackByIdArrayFn, trackByIdObjFn,
|
||||||
lhs, rhs, valueIdentifier, keyIdentifier,
|
lhs, rhs, valueIdentifier, keyIdentifier,
|
||||||
hashFnLocals = {$id: hashKey};
|
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() {
|
it('should track using provided function when a filter is present', function() {
|
||||||
scope.newArray = function (items) {
|
scope.newArray = function (items) {
|
||||||
var newArray = [];
|
var newArray = [];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue