run code on every route angular code example
Example: angular how to run code every time you route
ngOnInit(){
this.router.events.subscribe(event =>{
if (event instanceof NavigationStart){
console.log(event.url)
this.routerChangeMethod(event.url);
}
})
}
routerChangeMethod(url){
this.title = url;
}