fix(ngRepeat): allow extra whitespaces in (key,value) part of micro-syntax

e.g. (  aaa  ,   bbb  ) will be accepted by parser

Fixes #6827
Closes #6833
This commit is contained in:
Sekib Omazic
2014-03-25 13:24:06 +01:00
committed by Pawel Kozlowski
parent 081fef60b2
commit ef640cbc2a
2 changed files with 11 additions and 1 deletions

View File

@@ -257,7 +257,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) {
var aliasAs = match[3];
var trackByExp = match[4];
match = lhs.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/);
match = lhs.match(/^(?:(\s*[\$\w]+)|\(\s*([\$\w]+)\s*,\s*([\$\w]+)\s*\))$/);
if (!match) {
throw ngRepeatMinErr('iidexp', "'_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got '{0}'.",

View File

@@ -146,6 +146,16 @@ describe('ngRepeat', function() {
expect(element.text()).toEqual('misko:swe|shyam:set|');
});
it('should iterate over on object/map where (key,value) contains whitespaces', function() {
element = $compile(
'<ul>' +
'<li ng-repeat="( key , value ) in items">{{key}}:{{value}}|</li>' +
'</ul>')(scope);
scope.items = {me:'swe', you:'set'};
scope.$digest();
expect(element.text()).toEqual('me:swe|you:set|');
});
it('should iterate over an object/map with identical values', function() {
element = $compile(
'<ul>' +