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

Commit

Permalink
fix(ngRepeat): correct variable reference in error message
Browse files Browse the repository at this point in the history
Closese #803
  • Loading branch information
IgorMinar committed Mar 17, 2012
1 parent 78a6291 commit 935c101
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/directive/ngRepeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ var ngRepeatDirective = ngDirective({
}
lhs = match[1];
rhs = match[2];
match = lhs.match(/^([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\)$/);
match = lhs.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/);
if (!match) {
throw Error("'item' in 'item in collection' should be identifier or (key, value) but got '" +
keyValue + "'.");
lhs + "'.");
}
valueIdent = match[3] || match[1];
keyIdent = match[2];
Expand Down
11 changes: 9 additions & 2 deletions test/directive/ngRepeatSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,19 @@ describe('ng-repeat', function() {
}));


it('should error on wrong parsing of ng-repeat', inject(function($rootScope, $compile, $log) {
it('should error on wrong parsing of ng-repeat', inject(function($rootScope, $compile) {
expect(function() {
element = $compile('<ul><li ng-repeat="i dont parse"></li></ul>')($rootScope);
}).toThrow("Expected ng-repeat in form of '_item_ in _collection_' but got 'i dont parse'.");
}));


$log.error.logs.shift();
it("should throw error when left-hand-side of ng-repeat can't be parsed", inject(
function($rootScope, $compile) {
expect(function() {
element = $compile('<ul><li ng-repeat="i dont parse in foo"></li></ul>')($rootScope);
}).toThrow("'item' in 'item in collection' should be identifier or (key, value) but got " +
"'i dont parse'.");
}));


Expand Down

0 comments on commit 935c101

Please sign in to comment.