Я использую nativescript-urlhandler в своей Nativescript Aplication.Когда я помещаю маршрутизатор, мое приложение направляется сначала в LoginFirstComponent, а во вторую в ResetPassIdComponent, который я хочу.
Я хочу направить непосредственно к компоненту, который я хочу.
const routes: Routes = [
{
path: 'home',
component: HomeComponent,
canActivate: [AuthGuard],
children: [
{
path: 'fp', component: FirstPageComponent
},
{
path: 'profile', component: ProfileComponent
}
]
},
{
path: 'outsidelogin',
component: outsideloginComponent,
canActivate: [AuthGuardReset],
children: [
{ path: 'login', component: LoginFirstComponent },
{ path: 'register', component: RegisterComponent },
{ path: 'resetPasswordRequest/:id', component: ResetPassIdComponent }
]
},
{ path: '', redirectTo: '/home/fp', pathMatch: 'full' }
];
AuthGuard.ts
canActivate(): boolean {
if (this.auth.isAuthenticated()) {
return true;
}
this.router.navigate(['/outsidelogin/login']);
return false;
}
AuthGuardReset.ts
canActivate(): boolean {
if (this.auth.isAuthenticated()) {
return true;
}
this.router.navigate(['/outsidelogin/resetPasswordRequest/:id']);
return false;
}
Мой AuthGuardReset.ts не перемещается к ResetPassIdComponent, он остается в LoginFirstComponent.
В component.ts Iесть этот код:
ngOnInit() {
if (this.auth.isAuthenticated()) {
return true;
}
handleOpenURL((appURL: AppURL) => {
console.log('Got the following appURL', appURL);
this.myappurl = appURL
let url_1 = this.myappurl.toString();
let url_id = url_1.split("/").reverse()[0];
this.resetpasss = url_id
this.router.navigateByUrl('/outsidelogin/resetPasswordRequest/' + this.resetpasss);
});
}
Можете ли вы поделиться со мной любой идеей, как решить эту проблему, пожалуйста?