Premise:
i know that there are similar questions on StackOverflow, if i am asking this is because that solutions are not working in my case (or i am not able to apply them properly).
Situation:
I have an Angular js app with a map and a series of markers, which data and location are retrieved from a database. The app is working fine. I am using Angular-gm module: https://github.com/dylanfprice/angular-gm and i like it very much. When i click on the nav link i am redirected to the proper page with the map and i am seeing all the markers on the map.
The problem is that when i refresh the page, i loose all the markers, because that markers are retrieved with an $http call.
The code:
// Initialising the markers array.
$scope.markers= [];
// Getting the list of markers through $http call.
$http({
url: 'main/json_get_markers',
method: "POST",
}).success(function (data) {
$scope.markers = data;
});
Possible solutions:
Searching in StackOverflow and google i have found some possible solutions:
Using $route.reload();
If it is the right solution, then the question is: How can I exactly apply $route.reload(); in this case? Because i don't understand where exactly i have to put it. If i put it in the controller it generate an infinite loop, in the meaning that the page is continuosly refreshing.. So where have to be putted exactly?
Using ngStorage module: http://ngmodules.org/modules/ngStorag I see that is working fine in the demo, but i have tried to apply it in my case and was not able to obtain any result. So if this is the proper solution, then the question would be: How can i rewrite the $http call in order to save the results into the $localStorage?