I have a special service that stores specific objects to be shared among different controllers. Here is an example of the code I am using:
$rootScope.$on('controller.event', function(event, arg){
self.backendConnectorService.getBackendObject('99901').then(function(object){
if(object) {
self.myService.selectDeselectObject(object);
console.log(self.myService.getCurrentObject());
$state.go('myApp.mainArea.appsArea.objects.wizards');
}
});
After retrieving my object and navigating to the relevant state, I encounter an issue where
self.myService.getCurrentObject()
returns null when loading the controller for that state. However, the console.log
statement above displays the correct object. This inconsistency has led me to question whether services are truly singletons. Can you offer any insights into this?