I was able to get the authkey
value using route paramMap
, but how do we get the url. For example, I want to check if URL contains resetpassword
text as you can see on the link below. How do we do that in Angular?
How do we get URL or if URL contains certain text on page load? Check if URL contains "resetpassword" text.
Code
ngOnInit(): void {
this.router.paramMap.subscribe((paramMap) => {
console.log("paramMap" , paramMap)
this.code = paramMap.get('authkey');
if (this.code) {
this.code = paramMap.get('authkey').replace('authkey:', '');
this.getEmail(this.code);
}
});
}
Example URL
http://localhost:4200/#/login/resetpassword/authkey:6762b362-1a62-4077-8ae4-78b381REX7JEXE4a8f30