【发布时间】:2020-07-02 19:53:18
【问题描述】:
我有一个依赖于服务的分页组件。
我需要在顶部和底部位置的某些页面中重用它一个组件。
我应该创建一个pagination.module 来注册分页服务和组件,还是只在app.module 中声明分页组件?
同时发出分页组件包含翻译管道:| translate。
该管道在app.module注册,在PaginationComponent不可用
分享模块是:
@NgModule({
imports: [CommonModule, HeaderModule, FooterModule, ReactiveFormsModule, MaterialModule, FormsModule],
declarations: [
BadgeComponent,
LegendaComponent,
DateControlBadgeDirective,
CollectionStatusDocsDirective,
OrderFilterComponent,
SortringComponent,
SignDocumentComponent,
NavNotificationsComponent,
LoaderComponent,
FilterComponent,
DropdownExecutorsComponent,
ListFilterPipe,
SortByPipe,
ApplicationNamePipe,
PaginationComponent,
],
exports: [
BadgeComponent,
SignDocumentComponent,
LoaderComponent,
SortringComponent,
FilterComponent,
DropdownExecutorsComponent,
LegendaComponent,
ApplicationNamePipe,
PaginationComponent,
DateControlBadgeDirective,
CollectionStatusDocsDirective,
HeaderModule,
FooterModule,
ReactiveFormsModule,
MaterialModule,
FormsModule,
ListFilterPipe,
SortByPipe,
ApplicationNamePipe,
],
})
export class SharedModule {}
应用模块是:
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient],
},
}),
BrowserAnimationsModule,
MaterialModule,
HeaderModule,
FooterModule,
DashboardModule,
OrdersDistributionModule,
OrdersExecutionModule,
],
providers: [{ provide: LOCALE_ID, useValue: 'ru' }],
bootstrap: [AppComponent],
})
export class AppModule {}
【问题讨论】: