I've encountered a strange behavior while using loadChildren in my application and I'm quite confused about why it's happening.
Here is the content of my app-routing-module.ts
:
const routes: Routes = [
{
path: '',
redirectTo: 'home',
pathMatch: 'full'
},
{
path: 'home',
component: InformationPageComponent,
data: {
title: 'INFO',
preTitle: 'VISUALIZZA_MODELLO'
},
},
{
path: '',
loadChildren: './visualizza-modello/modello.module#ModelloModule',
canActivateChild: []
},
{
path: '**',
component: PageNotFoundComponent//HomeComponent
}
];
Furthermore, in my modello-routing-module.ts, this is what I have:
@NgModule({
imports: [
RouterModule.forChild([
{
path: 'visualizza-modello',
data: {
title: 'DELEGHE',
breadcrumb: 'VISUALIZZA_MODELLO',
preTitle: 'VISUALIZZA_MODELLO',
},
children: [
{
path: 'dettaglio-ditta',
data: {
title: 'RICERCA_PAT',
breadcrumb: 'RICERCA_PAT',
preTitle: 'VISUALIZZA_MODELLO'
},
children: [
{
path: 'dettaglio-quadro',
data: {
title: 'DETTAGLIO_MODELLO',
breadcrumb: 'VISUALIZZA_MODELLO',
preTitle: 'VISUALIZZA_MODELLO'
},
component: DettaglioQuadroComponent
},
{
path: '',
data: {
title: 'RICERCA_PAT',
breadcrumb: '',
preTitle: 'VISUALIZZA_MODELLO'
},
component: DettaglioDittaComponent,
}
]
},
{
path: '',
data: {
title: 'DELEGHE',
breadcrumb: '',
preTitle: 'VISUALIZZA_MODELLO'
},
component: DelegheComponent
},
]
},
])
],
exports: [RouterModule]
})
My desired behavior is as follows:
Upon opening the project, I'd like to be routed to the home page. When clicking on the "Visualizza Modello" menu item, I expect to be taken to that specific page. And if I click on "Home" within the breadcrumb navigation, I should return to the home page.
While this setup generally works, there are occasions when leaving and returning to the page results in only a blank page being displayed instead of the home page.
If you have any ideas on how to resolve this issue, please share them with me!