Search code examples
javascriptangularjsangularjs-track-by

Angular duplicates track by


I have this plunk:

http://plnkr.co/edit/7X8VMG?p=preview

and when I filter by clicking "Uncompleted" I'm getting the duplicates error in repeater

 Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: node in nodes track by node.id, Duplicate key: 1441, Duplicate value: {"name":"1","id":1441,"created_at":...

But if you look to the code, there is only one node with ID 1441. I've tried to put there others track by options, but nothing worked.

//Update info: Track by $index doesn't work because of nested structure

How to fix it?

Thanks a lot!

David


Solution

  • There was an error in setFilterOptions function that there was more status with same code and then it pushed more often the node to the result array.

    fixed by

    if($scope.current_visibility.since === null) {
        $scope.filters.tasks.statuses = angular.copy($scope.active_statusses);
        $scope.filters.tasks.statuses.push($scope.folder_status);
    }
    

    Thanks for help