I'm facing an issue with transferring data from controller A to controller B using a Factory (or a Service) when the user refreshes the browser. I am able to successfully set the data in controller A and retrieve it in controller B, but upon refreshing the page while on the controller B view, the data is lost and returns as "undefined". I believe using $localStorage could help solve this problem, any suggestions? What could be causing this issue?
The service factory I have implemented is quite straightforward, with an object defined as:
var obj = {};
and two methods:
return{
getObj: function(){return obj;},
setObj: function(data){ obj = data;}
};
Controller A utilizes the setObj method, while controller B makes use of getObj. Everything functions properly the first time around, but encountering a page refresh while on the controller B view results in loss of data.