你好,我有兩個模塊被延遲加載。你如何以角度共享模塊4
GroupModule和TaxModule。
在GroupModule中加載這個。
@NgModule({
imports: [
GroupRoutingModule,
CommonModule,
HttpClientModule,
FormsModule,
DataTableModule,
],
declarations: [
GroupListComponent,
GroupCreateComponent,
GroupEditComponent,
DataFilterPipe,
],
providers: [GroupService]
})
在我的TaxModule中我加載了這個。
@NgModule({
imports: [
CommonModule,
TaxRoutingModule,
HttpClientModule,
FormsModule,
DataTableModule,
],
declarations: [
TaxListComponent,
TaxCreateComponent,
TaxEditComponent,
DataFilterPipe,
],
providers: [TaxService]
})
問題是我得到這個控制檯錯誤。
ERROR Error: Uncaught (in promise): Error: Type DataFilterPipe is part of the
declarations of 2 modules: TaxModule and GroupModule! Please consider moving DataFilterPipe to a higher module that imports TaxModule and GroupModule. You can also create a new NgModule that exports and includes DataFilterPipe then import that NgModule in TaxModule and GroupModule.
Error: Type DataFilterPipe is part of the declarations of 2 modules: TaxModule and GroupModule! Please consider moving DataFilterPipe to a higher module that imports TaxModule and GroupModule. You can also create a new NgModule that exports and includes DataFilterPipe then import that NgModule in TaxModule and GroupModule.
我將DataFilterPipe添加到根應用程序模塊,但它不工作。任何人都知道這個問題的解決方案。
的AppModule
@NgModule({
imports: [
BrowserModule,
AppRoutingModule,
BsDropdownModule.forRoot(),
TabsModule.forRoot(),
ChartsModule,
],
declarations: [
AppComponent,
FullLayoutComponent,
NAV_DROPDOWN_DIRECTIVES,
BreadcrumbsComponent,
SIDEBAR_TOGGLE_DIRECTIVES,
AsideToggleDirective,
],
providers: [
{
provide: LocationStrategy,
useClass: HashLocationStrategy,
}, DataFilterPipe
],
bootstrap: [AppComponent]
})
這是我app.routing
export const routes: Routes = [
{
path: '',
component: LoginComponent,
data: {
title: 'Login'
}
},
{
path: 'dashboard',
redirectTo: 'dashboard',
pathMatch: 'full',
},
{
path: '',
component: FullLayoutComponent,
data: {
title: 'Home'
},
children: [
{
path: 'dashboard',
loadChildren: './dashboard/dashboard.module#DashboardModule'
},
{
path: 'store',
loadChildren: './store/store.module#StoreModule'
},
{
path: 'group',
loadChildren: './group/group.module#GroupModule'
},
{
path: 'tax',
loadChildren: './tax/tax.module#TaxModule'
}
]
}
莫非你顯示你的根AppModule的@NgModule? (只是想看看它是如何與TaxModule&GroupModule一起書寫的) – amal