aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Minar2012-03-17 15:57:55 -0700
committerIgor Minar2012-03-17 15:57:55 -0700
commit935c1018da05dbf3124b2dd33619c4a3c82d7a2a (patch)
treee221f3c1597ff292ffa9483495701a0b92a251c8
parent78a6291666d55c8b1415e8090c7e6a35ae95df8b (diff)
downloadangular.js-935c1018da05dbf3124b2dd33619c4a3c82d7a2a.tar.bz2
fix(ngRepeat): correct variable reference in error message
Closese #803
-rw-r--r--src/directive/ngRepeat.js4
-rw-r--r--test/directive/ngRepeatSpec.js11
2 files changed, 11 insertions, 4 deletions
diff --git a/src/directive/ngRepeat.js b/src/directive/ngRepeat.js
index efa27153..82f8b9c7 100644
--- a/src/directive/ngRepeat.js
+++ b/src/directive/ngRepeat.js
@@ -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];
diff --git a/test/directive/ngRepeatSpec.js b/test/directive/ngRepeatSpec.js
index 8b6a5173..85aa1511 100644
--- a/test/directive/ngRepeatSpec.js
+++ b/test/directive/ngRepeatSpec.js
@@ -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'.");
}));