Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 2e9dc5e

Browse files
committed
fix(ngRepeat): allow extra whitespaces in (key,value) of ngRepeat
Whitespaces allowed in (key,value) expression of ngRepeat. e.g. ( aaa , bbb ) will be accepted by parser closes #6827
1 parent ccba305 commit 2e9dc5e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/ng/directive/ngRepeat.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
240240
};
241241
}
242242

243-
match = lhs.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/);
243+
match = lhs.match(/^(?:(\s*[\$\w]+)|\(\s*([\$\w]+)\s*,\s*([\$\w]+)\s*\))$/);
244244
if (!match) {
245245
throw ngRepeatMinErr('iidexp', "'_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got '{0}'.",
246246
lhs);

test/ng/directive/ngRepeatSpec.js

+10
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,16 @@ describe('ngRepeat', function() {
109109
expect(element.text()).toEqual('misko:swe|shyam:set|');
110110
});
111111

112+
it('should iterate over on object/map where (key,value) contains whitespaces', function() {
113+
element = $compile(
114+
'<ul>' +
115+
'<li ng-repeat="( key , value ) in items">{{key}}:{{value}}|</li>' +
116+
'</ul>')(scope);
117+
scope.items = {me:'swe', you:'set'};
118+
scope.$digest();
119+
expect(element.text()).toEqual('me:swe|you:set|');
120+
});
121+
112122
it('should iterate over an object/map with identical values', function() {
113123
element = $compile(
114124
'<ul>' +

0 commit comments

Comments
 (0)