전체 페이지뷰

2016년 1월 27일 수요일

angular js error page

I don't know that I push the duplicate data in angular js

$scope.timelines = [];
$scope.timelines = response["data"];
angular.forEach(response["data"], function(obj) {
    $scope.timelines.push(obj);
});
 
cs
Angular js notify that you have duplicate data
Duplicate keys are banned because Angular js uses keys to associate DOM nodes with item.
I was so surprised with error link site
It explained you can solve your mistake in detail.
first show Error Description
second display solution.

Description

Occurs if there are duplicate keys in an ngRepeat expression. Duplicate keys are banned because AngularJS uses keys to associate DOM nodes with items.
By default, collections are keyed by reference which is desirable for most common models but can be problematic for primitive types that are interned (share references).
For example the issue can be triggered by this invalid code:
<div ng-repeat="value in [4, 4]"></div>
To resolve this error either ensure that the items in the collection have unique identity or use the track by syntax to specify how to track the association between models and DOM.
The example above can be resolved by using track by $index, which will cause the items to be keyed by their position in the array instead of their value:
<div ng-repeat="value in [4, 4] track by $index"></div>
but I solve other way to reject the duplicate data

댓글 없음:

댓글 쓰기