this.subscription = this.router.events.subscribe((event:Event) => {
console.log(event.url); ##### Error : Property 'url' does not exist on type 'Event'.
}
Typescript doesn't recognize the properties of the type Event that is built into the Angular Router. Is there something on tsd that I can use to solve this? Event is the super class of classes NaviagationEnd, NavigationStart
You have to import { Event } from @angular/router;
. Try moving console into the if
block with condition.
this.subscription = this.router.events.subscribe((event:Event) => {
if(event instanceof NavigationEnd ){
console.log(event.url);
}
});