I have this router.ts
{ path: 'resetPasswordRequest/:id', component: ResetPassIdComponent, canActivate: [AuthGuard]}
In component ResetPassIdComponent I get id with this code:
ngOnInit(): any {
let myid = this.route.snapshot.paramMap.get("id")
this.id = myid;
}
I want to now, how to create a AuthGurad which it navigate in this component ResetPassIdComponent.
I try to use this code but doesen't work
Update:
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
let productId = route.params.id;
if (this.auth.isAuthenticated()) {
return true;
}
this.router.navigate(['/resetPasswordRequest/' + productId]);
return false;
}
show in console: resetPasswordRequest/123456789
But not navigate in here component.