I have a web app running at Angular 9 and ASP.NET core v2.2, and I have these Routes at app-routing.module.ts,
const routes: Routes = [
{
path: '',
loadChildren: () => import('./layouts/website-layout/website-layout.module').then(mod => mod.WebsiteLayoutModule),
},
{
path: '**',
pathMatch: 'full',
loadChildren: () => import('./error-page/error-page.module').then(mod => mod.AppErrorPageModule)
}
];
The website-layout-routing.module.ts contains many children routes. For example:
const routes: Routes = [
{
path: '',
component: WebsiteLayoutComponent,
children: [
{
path: WebSitePagesRoutes.LegaL.TermsOfUsePage,
loadChildren: () => import('../../website-pages/terms-of-use/terms-of-use.module').then(mod => mod.TermsOfUseModule)
},
{
path: WebSitePagesRoutes.LegaL.PrivacyPolicyPage,
loadChildren: () => import('../../website-pages/privacy-policy/privacy-policy.module').then(mod => mod.PrivacyPolicyModule)
},
]
The website-layout.component.html contains this code:
<div class="app-container">
<app-navbar>
<div class="app-content-wrapper"
<main>
<router-outlet></router-outlet>
</main>
<footer>
<app-footer></app-footer>
</footer>
</div>
</app-navbar>
</div>
And each children loaded at website-layout-routing.module.ts contains the minimal routing configuration possible. For example:
routes: Routes = [
{
path: '',
component: TermsOfUsePageComponent
}
];
When I enter a page, for example the main page of the web app, the website-layout-routing.module.ts loads with a number of .js files with a prefix of default~, as in the following image:
I believe this is the default page of any module found under website-layout.module.ts.
It seems that in my case, the app-routing.module.ts loads all the default pages that are under website-layout-routing.module.ts, even though I'm not on those pages. Here's a callstack for each default~ .js shown in the previous screenshot.
How can I prevent it from happening?

