以下按预期工作,当用户导航到/登录时,他们会获得正确的路径。
应用程序的路由
const ROUTES: Routes = [
{
path: 'home',
component: HomeComponent,
canActivate: [AuthGuard]
},
{
path: 'onboarding',
loadChildren: 'app/onboarding/onboarding.module#OnboardingModule',
// canActivate: [AuthGuard]
},
{
path: '',
redirectTo: 'home',
pathMatch: 'full'
},
// { path: '**', redirectTo: 'home' }
];
初始启用路由
const routes: Routes = [
{
path: '',
component: OnboardingComponent
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class OnboardingRoutingModule { }
onboarding.module
@NgModule({
imports: [
SharedModule,
AngularFirestoreModule,
OnboardingRoutingModule
],
declarations: [OnboardingComponent]
})
export class OnboardingModule {}
当我更新OnboardingModule
以使用ModuleWithProviders
时出现问题,当用户导航到/onboarding
时,他们会被重定向到/onboarding/home
更新了入职模块
@NgModule({
imports: [SharedModule],
declarations: [OnboardingComponent]
})
export class OnboardingModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: RootOnboardingModule,
providers: [],
};
}
}
@NgModule({
imports: [
OnboardingModule,
AngularFirestoreModule,
OnboardingRoutingModule,
// StoreModule.forFeature('onboard', reducers),
// EffectsModule.forFeature([OnboardingEffects]),
],
})
export class RootOnboardingModule {}