Recently, I encountered an issue with a SERVICE named test.service, which contains an object:
public locationObject = {
......
......
currency: string
}
In my project, this SERVICE is injected into the HeaderComponent and the object locationObject is initialized in ngOnInit. Everything seems fine, but when a user logs in, I use router.navigate to redirect them to a dashboard.
..
this.router.navigate(['owner-dashboard']);
The same SERVICE is also injected into the loginComponent and ownerDashboardComponent, allowing me to access the properties of locationObject in the ownerDashboardComponent. However, upon refreshing the screen, I noticed that locationObject becomes undefined. Additionally, after some time, the header component refreshes itself and resets the locationObject. This raises questions about why I lose locationObj despite the refreshed header.
I have a vague understanding of what might be happening here, but I would appreciate it if someone could explain it to me. Thank you.
EDIT. core html: