I have a problem with refreshing from localStorage.
I have list of items. I can display them. I add one item to array and display.
Everything works fine. I can display. I can see that another object was added to items array.
When I close and reopen app. The alert shows object exists and has correct number of items. Only problem is I dont see the items now in the view.
Is this $scope problem or async problem. The array exists..
Edit:
I have array with three items. I push to localstorage, first. then use data from localstorage to bring into '$scope.items'.
In the view, the data is shown from '$scope.items'. Everything works as expected. I turn off app turn back on, And the array loads properly from localstorage. This is not a problem.
Now, the view has ability to add to array. I can add to array, Again loading from localstorage. There is an alert, which shows that the array has one more object. I can add another item and ..... All of them show up in the view. All updates come from localstorage.
I turn app on and off, there is nothing in the view. This is done on a phone so I cant check localstorage.
You did not post any code so I will just do my best to help. are you fetching items from local storage and setting to to a $scope variable? also fetching the item from local storage on app load and put it in a service or do it before the view that needs the data enters the view. like this:
$scope.$on('$ionicView.beforeEnter', function () {
$scope.items = localStorage.getItem('youritem');
});
This solved the problem. It was a ng-repeat issue.
<div ng-repeat="row in [1,1,1] track by $index">