Моя заявка имеет следующую структуру:
app.module.ts
const routes: Routes = [
{ path: '', loadChildren: './modules/main/main.module#MainModule' },
];
@NgModule({
declarations: [
AppComponent,
],
imports: [
RouterModule.forRoot(routes),
],
providers: [
AuthService,
UtilService,
UserService
],
bootstrap: [AppComponent]
})
export class AppModule {
}
main.module.ts
@NgModule({
declarations: [
PressComponent,
LegalComponent
],
providers: [
AuthService
],
imports: [
HomeModule,
MainRoutingModule,
]
})
export class MainModule {
}
main.routing.component.ts
const routes: Routes = [
{ path: '', component: HomeComponent, canActivate: [AnonymousGuard] },
{ path: 'home', component: HomeComponent, canActivate: [AnonymousGuard] },
{ path: '**', redirectTo: '', pathMatch: 'full' }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class MainRoutingModule implements OnInit {
constructor() { }
ngOnInit() {
RouterModule.forRoot(routes, { scrollPositionRestoration: 'enabled' });
}
}
По какой-то причине просмотр к /home
работает, но /
- нет.Как я могу это исправить?