I'm loading the URL on my app page. In that, if the URL parameter will change after clicking submit - how to get the changes of the parameter in the URL?

updateUrl() {
   console.log('check');
   let localaccesstoken = localStorage.getItem('token');
   let Url = 'http://abcd.net/outfit/index.php?option=com_j2store&view=checkout&mobile=mobile&tmpl=component';
   let checkoutPage = window.open(Url, '_self');
   console.log(JSON.stringify(checkoutPage));
   return this.sanitizer.bypassSecurityTrustResourceUrl(Url);
}

The above function will lose the URL.

Help me to capture the URL if any changes happen.

1 Answers

0
Edison On

In angular we can subscribe (Rx event) to a Router instance

class MyClass {
  constructor(private router: Router) {
    router.events.subscribe((val) => {
        // see also 
        console.log(val instanceof NavigationEnd) 
    });
  }
}

or

this.router.events.subscribe(event: Event => {
    // Handle route change
});