Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #angular #run #code #time #route
ADD COMMENT
Topic
Name
6+1 =