Refresh a list on the screen


#1

Hi. I have a list with an item. When I click on this item, I reload the list with two new items. but the previous item remains on the screen for a while along with new items and then disappears.


#2

Noone here will get far without a piece of code.
Help us help you


#3

OK I understand. Thank you anyway.
I do not even know what part of the code show you.
I will try to make an example to post here.


#4

It sounds like you are first adding new items to the list and then removing the old one, if that’s the case, why not just substitute the showing array with the second one?


#5

I’m doing it. When the array returns from the service, I do some processing on it, but first I make:

// at this point, items has the old items
$scope.items = [];
// myService defers a promise
myService.getItems(clickedItem).then(function(data){
$scope.items = data; // this is the new items
});
// items is the array that I use in the ng-repeat

So I expected the previous items have been removed.
I walked around the problem by creating a new list and hiding the previous one.

thx for your attention