Within my application, there are two modules: IdentityModule and ServiceModule
. These modules are loaded using lazy loading technology.
I've recently developed a custom directive called IconSpacerDirective
, which is bound to app.module.ts
. This directive functions perfectly within my app.component.ts
.
However, I am encountering an issue when trying to use the IconSpacerDirective
within the IdentityModule
. The error message reads:
ERROR Error: Uncaught (in promise): Error: Type IconSpacerDirective is part of the declarations of 2 modules: AppModule and IdentityRegistryModule! Please consider moving IconSpacerDirective to a higher module that imports AppModule and IdentityRegistryModule. You can also create a new NgModule that exports and includes IconSpacerDirective then import that NgModule in AppModule and IdentityRegistryModule.
Error: Type IconSpacerDirective is part of the declarations of 2 modules: AppModule and IdentityRegistryModule! Please consider moving IconSpacerDirective to a higher module that imports AppModule and IdentityRegistryModule. You can also create a new NgModule that exports and includes IconSpacerDirective then import that NgModule in AppModule and IdentityRegistryModule.
Below is the snippet from my identityRegistryModule
:
import { IconSpacerDirective } from '../shared/custom-directive/icon-spacer.directive';
@NgModule({
declarations: [
IconSpacerDirective
],
imports: [
IdentityRegistryRoutingModule,
MaterialModule
],
providers: [
IdentityService,
],
})
export class IdentityRegistryModule { }
The code from my app.module.ts
is as follows:
import { IconSpacerDirective } from './shared/custom-directive/icon-spacer.directive';
@NgModule({
declarations: [
AppComponent,
MainNavComponent,
SideNavComponent,
HeaderComponent,
HomeComponent,
IconSpacerDirective,
],
imports: [
BrowserModule,
HttpClientModule,
AppRoutingModule,
FlexLayoutModule,
BrowserAnimationsModule,
LayoutModule,
MaterialModule,
OAuthModule.forRoot(),
],
providers: [],
bootstrap: [AppComponent],
//exports: [IconSpacerDirective]
})
export class AppModule { }
Is there a way for me to utilize the IconSpacerDirective
within my identityRegistryModule
?