diff --git a/src/ng/directive/ngRepeat.js b/src/ng/directive/ngRepeat.js index 95effc6d33fc..aeb0fb8ecf00 100644 --- a/src/ng/directive/ngRepeat.js +++ b/src/ng/directive/ngRepeat.js @@ -267,7 +267,7 @@ var ngRepeatDirective = ['$parse', '$animate', function($parse, $animate) { var keyIdentifier = match[2]; if (aliasAs && (!/^[$a-zA-Z_][$a-zA-Z0-9_]*$/.test(aliasAs) || - /^null|undefined|this|\$index|\$first|\$middle|\$last|\$even|\$odd|\$parent$/.test(aliasAs))) { + /^(null|undefined|this|\$index|\$first|\$middle|\$last|\$even|\$odd|\$parent)$/.test(aliasAs))) { throw ngRepeatMinErr('badident', "alias '{0}' is invalid --- must be a valid JS identifier which is not a reserved name.", aliasAs); } diff --git a/test/ng/directive/ngRepeatSpec.js b/test/ng/directive/ngRepeatSpec.js index d2d81a6af87f..9f7aada2175c 100644 --- a/test/ng/directive/ngRepeatSpec.js +++ b/test/ng/directive/ngRepeatSpec.js @@ -418,6 +418,36 @@ describe('ngRepeat', function() { }); + it('should support alias identifiers containing reserved words', inject(function($exceptionHandler) { + scope.x = 'bl'; + scope.items = [ + { name : 'red' }, + { name : 'blue' }, + { name : 'green' }, + { name : 'black' }, + { name : 'orange' }, + { name : 'blonde' } + ]; + forEach([ + 'null2', + 'qthis', + 'qthisq', + 'fundefined', + '$$parent' + ], function(name) { + var expr = 'item in items | filter:x as ' + name + ' track by $index'; + element = $compile('