I have a project in Nativescript. My problem in my project is in CanActivate. My canActivate don't navigate in another page when use AuthGuard.
I have this routing.ts:
const routes: Routes = [
{
path: 'home',
component: HomeComponent,
canActivate: [AuthGuard],
children: [
{
path: 'fp', component: FirstPageComponent
}
]
},
{
path: 'outsidelogin',
component: outsideloginComponent,
children: [
{ path: 'login', component: LoginFirstComponent },
{ path: 'register', component: RegisterComponent },
]
},
{
path: 'test',
component: outsideloginComponent,
canActivate: [AuthResetGuard],
children: [
{ path: 'resetPasswordRequest/:id', component: ResetPassIdComponent }
]
},
{ path: '', redirectTo: '/home/fp', pathMatch: 'full' }
];
in AuthResetGuard.ts I have this code:
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
let productId = route.params.id;
if (this.auth.isAuthenticated()) {
return true;
}
this.router.navigate(['/test/resetPasswordRequest/' + productId]);
console.log('/test/resetPasswordRequest/' + productId)
return true;
}
In this ResetPassIdComponent .ts I have
ngOnInit(): any {
let myid = this.route.snapshot.paramMap.get("id")
this.id = myid;
}
ERROR: When I click in http://xxxxxx.com/v1/resetPasswordRequest/11111, My application don't open , only show splash_screen and in console show all of time only
JS: /test/resetPasswordRequest/11111
JS: /test/resetPasswordRequest/11111
JS: /test/resetPasswordRequest/11111
JS: /test/resetPasswordRequest/11111
JS: /test/resetPasswordRequest/11111
Any idea please, how to solution my problem ?