I am currently working with Angular 4 and have written the following code in one of my components to detect when a route has changed and reload the page:
ngOnInit() {
this.router.events.subscribe((value) => {
if (value instanceof NavigationEnd) {
console.log(value);
}
});
}
However, I am encountering an issue where multiple 'NavigationEnd' events are triggered for a single route change. In some cases, the console logs up to 6 or 7 values.
Why is this happening?