I'm looking for a way to reload or refresh a sidebar component when the route changes. Below is the code I currently have:
constructor(
private auth: AuthService,
private router: Router,
private changeDetector: ChangeDetectorRef
) {
this.auth.currentUser.subscribe(x => this.userData = x);
this.router.events.subscribe((event) => {
if (event instanceof NavigationStart) {
this.changeDetector.detectChanges();
console.log('enter');
}
});
}
The 'enter' log is displayed, but the component is not reloaded. Can anyone provide an example of how to achieve this?