0
我已將我的app.module.ts分成多個模塊,但是這會導致我無法解決的錯誤。我得到的錯誤:Angular2 ngModule split會導致錯誤
Template parse errors: 'generic-titlepagebar' is not a known element
這是我的模塊,這些模塊使用仿製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 { }
和通用-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 {}
我試着將它添加爲:exports:[GenericComponentsModule],但Module已經導出爲導出類GenericComponentsModule {} – viddrawings
您需要將具有選擇器的組件:'generic-titlepagebar'(不是模塊)放入出口 –
我也試過,但它似乎也沒有工作... – viddrawings