-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

1 Answer 1

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)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.