I have made a page for users to reset their password if they forget it. Users will get an email that will contain the link of reset password page along with reset token.
URL of password page should look like this:
Here are is my route in router module and reset password page ngOnInit() code:
const routes: Routes = [
{path: 'resetpassword?code=/:code', component: ResetpasswordComponent}
];
ngOnInit() {
debugger;
const param = this.route.snapshot.paramMap.get('code');
if(param) {
this.Code = param;
}
}
I want to know:
Anyone who can guide me how can I build a route like this and read the params value?
path should be:
{path: 'resetpassword', component: ResetpasswordComponent}
navigation:
<a
routerLink="/resetpassword"
[queryParams]="{code: 'CfDJ8LBxIxG2Gf5IjZZG9p+g7oDJxTqYPL7OnGSOIblOksnbNniISOo/jKuZ8RkPriLpsCle5VNwVII5O+r9KPmos1WcwmKCB5mMbYeO/tVKxUiqymsEDFjvWEt0X+KfIQlPbe8fvTMtAaB07IG01vwT2UWn+CjEAYwcZgV6eKhPEP21U9lxLxeG8bE6SXMwninNvWI1lf6jm3Ia1MIDikqL9EC033AMIGlnjvEonbxV+Jb'}"
>
</a>
in resetPassword component:
constructor(private activeRoute: ActivatedRoute) {
activeRoute.queryParams
.subscribe((params) =>
{
console.log(params)
});
}
check DEMO.