Is there a way to detect route changes only within the DetailsComponent without being triggered for every route start and end event? I attempted the following approach, but it's currently capturing events for all routes.
export class DetailsComponent {
constructor(private router: Router) {
this.router.events.subscribe((event: Event) => {
if (event instanceof NavigationStart) {
// Code to handle navigation start
}
if (event instanceof NavigationEnd) {
// Code to handle navigation end
}
});
}
}
I specifically need to capture the URL during navigation in the DetailsComponent and perform an operation only if the URL is not "/employees".