0

I am using http request with angular js ng-repeat to repopulate a list.

it goes like this:

<div class="item" ng-repeat="item in itemlist">
    content goes here...
</div>

than, in the controller, I call a function with interval, that sets item variable to be the new list:

$app.communicate is a function that makes http request to the server

    initializeItemList = function() {
        $app.communicate('item','loadItemList',{user_id : localStorage.userId},function(data, status, headers, config) {
            $scope.recent_item = data.recent_item;
            $scope.itemlist= data.itemlist;
            }
        },function() {});       
    };

    initializeItemList();

    $interval(initializeItemList, 4000);

in practice, every interval run duplicates the itemlist.

I tried to add filter unique, but it won't help..

1 Answer 1

4

Use track by

<div class="item" ng-repeat="item in itemlist track by $index">
    content goes here...
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.