I have key value pair of component classes, which i used to generate routing dynamically.
example -
export const NODE_COMPONENT = {
climate: ClimatePageComponent,
project: ProjectDataPageComponent,
}
export const NODE_MODULE = {
climate: ClimateModule,
project: ProjectModule,
}
Now I want to use these key value pair to generate declaration, entryComponent & imports using below code -
@NgModule({
declaration: [ otherComponents ],
import: [otherModules],
})
export class PageModule {
constructor(private module: NgModule) {
this.loadImports();
}
loadImports() {
for (const key in NODE_COMPONENT) {
this.module.declarations.push(NODE_COMPONENT[key]);
this.module.entryComponents.push(NODE_COMPONENT[key]);
this.module.imports.push(NODE_MODULE[key]);
}
}
}
but it's throwing compilation error
Cannot determine the module for class ClimatePageComponent Add ClimatePageComponent to the NgModule to fix it
Let me know If it's possible or do i need to import it manually?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…