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() {
   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');
   return this.sanitizer.bypassSecurityTrustResourceUrl(Url);

The above function will lose the URL.

Help me to capture the URL if any changes happen.

1 Answers

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) 


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