У меня есть проект в Nativescript.Моя проблема в моем проекте в CanActivate.Мой canActivate не переходить на другую страницу при использовании AuthGuard.
У меня есть эти 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' }
];
в AuthResetGuard.ts У меня есть этот код:
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;
}
В этом ResetPassIdComponent .ts у меня есть
ngOnInit(): any {
let myid = this.route.snapshot.paramMap.get("id")
this.id = myid;
}
ОШИБКА: когда я нажимаю http://xxxxxx.com/v1/resetPasswordRequest/11111, Мое приложение не открывается, показывается только splash_screen, а в консоли показывается только все время
JS: /test/resetPasswordRequest/11111
JS: /test/resetPasswordRequest/11111
JS: /test/resetPasswordRequest/11111
JS: /test/resetPasswordRequest/11111
JS: /test/resetPasswordRequest/11111
Любая идея, пожалуйста, как решить мою проблему?