mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 03:55:49 +08:00
fix(ngRepeat): improve errors for duplicate items
-Log the value that had the duplicate key, as well as the key The error that is thrown when items have duplicate track by keys can be confusing because only the duplicate key is logged. If the user didn't provide that key themselves, they may not know what it is or what item it corresponds to.
This commit is contained in:
@@ -940,7 +940,8 @@ describe('ngRepeat', function() {
|
||||
scope.items = [a, a, a];
|
||||
scope.$digest();
|
||||
expect($exceptionHandler.errors.shift().message).
|
||||
toMatch(/^\[ngRepeat:dupes\] Duplicates in a repeater are not allowed\. Use 'track by' expression to specify unique keys\. Repeater: item in items, Duplicate key: object:003/);
|
||||
toMatch(
|
||||
/^\[ngRepeat:dupes\] Duplicates in a repeater are not allowed\. Use 'track by' expression to specify unique keys\. Repeater: item in items, Duplicate key: object:003, Duplicate value: {}/);
|
||||
|
||||
// recover
|
||||
scope.items = [a];
|
||||
@@ -960,7 +961,8 @@ describe('ngRepeat', function() {
|
||||
scope.items = [d, d, d];
|
||||
scope.$digest();
|
||||
expect($exceptionHandler.errors.shift().message).
|
||||
toMatch(/^\[ngRepeat:dupes\] Duplicates in a repeater are not allowed\. Use 'track by' expression to specify unique keys\. Repeater: item in items, Duplicate key: object:009/);
|
||||
toMatch(
|
||||
/^\[ngRepeat:dupes\] Duplicates in a repeater are not allowed\. Use 'track by' expression to specify unique keys\. Repeater: item in items, Duplicate key: object:009, Duplicate value: {}/);
|
||||
|
||||
// recover
|
||||
scope.items = [a];
|
||||
|
||||
Reference in New Issue
Block a user