-1

I need to check if my income URL is a specific formate then open modal and do something. I do this with this code:

route.queryParams.subscribe(async params => {
      if (!isNaN(params.rt)) {
        console.log("URL Match");
        this.show = true;
      } else {
        console.log("URL does not Match");
      }
    });

my format should be like :

www.example.com?=123456

but i need if complete modal Process, remove query param from url

heliya rb
  • 682
  • 8
  • 26

1 Answers1

1

To remove query params you can do like below.

let url: string = this.router.url.substring(0, this.router.url.indexOf("?"));
this.router.navigateByUrl(url); // where this.router will be intialized in ex:// constructor(private router:Router) {}

This link might help.

cleary query params in router (SO)

Pallamolla Sai
  • 2,337
  • 1
  • 13
  • 14