Hi everyone!
My controller retrieves some JSON data using an Angular $http request when someone uses the “Pull-to-Refresh” action. Here’s my onReload function in my controller:
$scope.onReload = function() {
$http.get('http://demourl.com/songs.json').success(function(data) {
$scope.items = data;
});
$scope.$broadcast('scroll.refreshComplete');
};
The problem is though, that the old Items stay in the list view together with the new ones, say, if the JSON array contains 2 items; A and B, the first time I pull to refresh there are 2 items (A and B) in the list, the second time I pull to refresh there are 4 items (A, B, A, B), the third time are 6 items in the list (ABABAB), and so on…
I can’t find anything suspicious in my controller code (above), nor in my view:
<content on-refresh="onReload()" scroll="true">
<refresher></refresher>
<item class="song" ng-repeat="item in items">
<img class="song--cover" src="{{item.song.cover}}">
</item>
</content>
Can you tell me what I’m doing wrong?