I try to implement lazy loading with clidren ans grandchildren. and even more challenger the components have the same name so I use aliases.
So inside one of my children, I import a grandchild in the html <app-Detail-index> part but I have errors.
Stack Angular 13
so a add shemas on NgModule and move loading of detail compents
'grandchild ' is not a known element:
1. If 'grandchild' is an Angular component, then verify that it is part of this module.
2. If 'grandchild' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.ngtsc
const routes: Routes = [
{ path: '', redirectTo: 'index', pathMatch: 'prefix'},
{ path: 'index', component: IndexComponent },
{ path: ':domId/view', component: ViewComponent },
{ path: 'create', component: CreateComponent },
{ path: ':domId/edit', component: EditComponent } ,
{ path: 'domDetail', loadChildren: () => import('../domDetail/domDetail.module').then(m => m.DomDetailModule) },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
})
export class DomRoutingModule { }
@NgModule({
declarations: [
CreateComponent,
EditComponent,
IndexComponent,
ViewComponent,
],
imports: [
CommonModule,
DomRoutingModule,
FormsModule,
ReactiveFormsModule,
]
})
export class DomModule { }
const routes: Routes = [
{ path: '', redirectTo: 'index', pathMatch: 'prefix'},
{ path: 'index', component: IndexComponent },
{ path: 'create', component: CreateComponent },
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
schemas: [
CUSTOM_ELEMENTS_SCHEMA
],
})
export class DomDetailRoutingModule { }
@NgModule({
declarations: [
CreateComponent,
IndexComponent,
],
imports: [
CommonModule,
DomDetailRoutingModule,
FormsModule,
ReactiveFormsModule,
]
})
export class DomDetailModule { }
const routes: Routes = [
{ path: 'home', loadChildren: () => import('./home/home.module').then(m => m.HomeModule)},
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'dom', loadChildren: () => import('./dom/dom.module').then(m => m.DomModule) },
{ path: '**', component: PageNotFoundComponent },
...
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
declarations: [
],
providers: [
],
})
export class AppRoutingModule { }
RouterModule.forChild(exampleRoutes).