• This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts

  • kevin
    Keymaster
    Postcount 45

    I want catch change url event and get current route in Angular 9. How can I do?


    kevin
    Keymaster
    Postcount 45

    You can use code sample below to do:

    import { Router, NavigationEnd } from ‘@angular/router’;
    constructor(
        private router: Router,
      ) { }
    this.router.events.subscribe(
          (event: any) => {
            if (event instanceof NavigationEnd) {
             console.log(this.router.url);
            }
          }
        );
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Top