0

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.

web site
  • 99
  • 8
  • This is a common error thrown when you don't have any route that matches given url segments. Also you have to pass actual id as second item in array to navigate function. I had been suggesting you to build a Playground so myself or anyone around can fix it for you. Posting similar questions with different titles are not going you help. – Manoj Dec 21 '18 at 15:52
  • Sorry, but I don't understand very well Playground , how to modify AndoridManifest.xml in Playground ? I update my post, if you can help me. Thank you! – web site Dec 21 '18 at 17:19
  • You don't have to, your question is all about Angular Routing right? Just presume you have the URL from app handler in the router guard. At worst case you may create a Github repo and share your sample project. – Manoj Dec 21 '18 at 17:24
  • I try to demonstrate my problem in this project `https://play.nativescript.org/?template=play-ng&id=E4U0vn` I want, when I click link to open a application in RestePassComponent . Thank You – web site Dec 24 '18 at 10:26
  • I don't see the issue, all I see is 2 buttons one for login and signup that does nothing but navigating to empty page with their titles. – Manoj Dec 24 '18 at 10:53
  • Yes, but when I click this link https://apitester.com/example/1 from email, I want to navigate directly in RestePassComponent. In this part is my problem – web site Dec 24 '18 at 11:07
  • https://play.nativescript.org/?template=play-ng&id=E4U0vn&v=2 – web site Dec 24 '18 at 11:08
  • @Manoj please I find my problem but I can't solution, can you see my post please, https://stackoverflow.com/questions/53921510/how-to-execute-in-first-a-function-and-in-second-canactivate – web site Dec 25 '18 at 11:31

0 Answers0