Access Parent Functionality from Child Module

236 views Asked by At

How do I properly set up a child module within the shared module of the application without getting circular dependency warnings or is it bad practice to have modules within modules?

I have a shared module containing shared functionality across the application. Within that shared module I have a module that needs to access the pipes in the shared module. In my example below the SchedulerModule needs to access the DigitToHourPipe which is declared in the SharedModule.

@NgModule({
  declarations: [DigitToHourPipe],
  imports: [CommonModule, AngularSplitModule],
  exports: [SchedulerModule, DigitToHourPipe]
})
export class SharedModule {}

@NgModule({
  declarations: [
    SchedulerComponent,
    EventViewComponent,
    EmployeeViewComponent,
    EventComponent
  ],
  imports: [CommonModule, AngularSplitModule.forRoot(), MatTableModule],
  exports: [SchedulerComponent]
})
export class SchedulerModule {}

Am I being stupid for having modules within modules or am I just doing something else wrong?

0

There are 0 answers