Chiien
Chiien

Reputation: 341

how to export module in father module to child

I have HomeModule, inside I have imports SharedModule with angular material and ToolbarModule. My doubt is how can I just import SharedModule in HomeModule and exports to all child modules, because I am import SharedModule for the child modules. Follow the code:

@NgModule({
  imports: [
    CommonModule,
    SharedModule,
    ToolbarModule
  ],
  exports: [
    HomeComponent
  ]
})
export class HomeModule { }

@NgModule({
  imports: [
    SharedModule
  ]
})
export class ToolbarModule { }

What is the best practice? Thanks a lot!

Upvotes: 1

Views: 133

Answers (1)

Giacomo Voß
Giacomo Voß

Reputation: 1067

Angular works that way, you will have to import all modules that you need inside the @NgModule. So you will have to import SharedModule as many times as you need it.

So your code is correct!

Upvotes: 1

Related Questions