I believe you understand what’s happening here
It fits into the controller of home:
$http({method: 'GET', url: urlNewV,
params: {time: 'All', lat: paramLat, lng:paramLng, UserId:paramUser}}).success(function(data, status) {
var dataToStore = JSON.stringify(data);
window.localStorage.setItem('allEventList', dataToStore);
});
.factory('EventService', function(){
var AllEventList = JSON.parse(window.localStorage.getItem('allEventList'));
return {
all: function() {
return AllEventList;
},
get: function(eventId) {
for(var i=0, l=AllEventList.length; i < l; i++) {
if(AllEventList[i].id == eventId) {
return AllEventList[i];
}
}
}
}
})
And it fits into the controller:
$scope.data = JSON.parse(window.localStorage.getItem('allEventList'));
The problem is, every time you go into the home page is loading new data but are not shown, I only see the old data (data uploaded first time entered the application)
If I check in Chrome’s console I see the new data
If I write this:
$scope.$watch(function(){
$scope.data = JSON.parse(window.localStorage.getItem('allEventList'));
});
I get an error:
Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: