我已将app.module.ts拆分为多个模块,但这会导致我无法解决的错误。我收到错误:
模板解析错误:' generic-titlepagebar'不是一个已知的元素
这些是我使用generic-titlepagebar的模块。
app.modules.ts:
@NgModule({
declarations: [
AppComponent,
LoginComponent
],
imports: [
BrowserModule,
MaterialModule,
FormsModule,
ReactiveFormsModule,
HttpModule,
BrowserAnimationsModule,
MdNativeDateModule,
Md2Module,
ResponsiveModule,
DataTableModule,
GridsterModule,
NgbDropdownModule.forRoot(),
AgmCoreModule.forRoot({
apiKey: 'AIzaSyD2lf1s8D8vkzHKxDWfkHqGAGsGLAWlNvw'
}),
CustomComponentsModule,
GenericComponentsModule,
ViewModule,
ServiceModule,
RouterModule.forRoot(appRoutes),
],
providers: [
{
provide: Http,
useFactory: httpFactory,
deps: [XHRBackend, RequestOptions]
}
],
bootstrap: [
AppComponent
]
})
export class AppModule { }
和generic-component.module.ts
@NgModule({
imports: [
CommonModule,
MaterialModule,
FormsModule,
ReactiveFormsModule,
HttpModule,
BrowserAnimationsModule,
RouterModule,
MdNativeDateModule,
Md2Module,
ResponsiveModule,
DataTableModule,
GridsterModule,
NgbDropdownModule.forRoot(),
AgmCoreModule.forRoot({
apiKey: 'AIzaSyD2lf1s8D8vkzHKxDWfkHqGAGsGLAWlNvw'
})
],
declarations: [
BackButtonComponent,
DynamicFormComponent,
DynamicFormQuestionComponent,
DynamicLoaderComponent,
GenericCardComponent,
GenericConfigComponent,
GenericListComponent,
GenericProjectSwitcherComponent,
GenericSearchComponent,
MapsComponent,
TableComponent,
TableDetailsComponent,
TabsbarComponent,
TitlePageBarComponent,
MenuComponent
],
entryComponents: [
GenericListComponent,
DynamicFormComponent,
GenericCardComponent,
GenericSearchComponent,
TableComponent
]
})
export class GenericComponentsModule {}
答案 0 :(得分:0)
如果你的generic-component.module中有一个带有选择器'generic-titlepagebar'的组件,你需要在你的generic-component.module的@NgModule声明的exports部分添加这个组件。然后,您可以在app.module中的某个组件的模板中使用标记<generic-titlepagebar>
。