Skip to content

Commit 20fd2b6

Browse files
committedNov 28, 2014
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 angular#6827
1 parent 30694c8 commit 20fd2b6

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
@@ -257,7 +257,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
257257
var aliasAs = match[3];
258258
var trackByExp = match[4];
259259

260-
match = lhs.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/);
260+
match = lhs.match(/^(?:(\s*[\$\w]+)|\(\s*([\$\w]+)\s*,\s*([\$\w]+)\s*\))$/);
261261

262262
if (!match) {
263263
throw ngRepeatMinErr('iidexp', "'_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got '{0}'.",

‎test/ng/directive/ngRepeatSpec.js

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

149+
it('should iterate over on object/map where (key,value) contains whitespaces', function() {
150+
element = $compile(
151+
'<ul>' +
152+
'<li ng-repeat="( key , value ) in items">{{key}}:{{value}}|</li>' +
153+
'</ul>')(scope);
154+
scope.items = {me:'swe', you:'set'};
155+
scope.$digest();
156+
expect(element.text()).toEqual('me:swe|you:set|');
157+
});
158+
149159
it('should iterate over an object/map with identical values', function() {
150160
element = $compile(
151161
'<ul>' +

0 commit comments

Comments
 (0)
Please sign in to comment.