ashfaq.p ashfaq.p - 1 year ago 71
Javascript Question

Do i need to add a plugin to every module in angular 2?

I am using

with angular 2. I have it imported in my
and it's working fine.

I am lazy-loading another module and
components are not working in that. They work if I import ng-bootstrap module again in the lazy-loaded module.

My question is: Do I need to import 3-rd party modules again in every module I write or there is some way of making them to work by some setting ?

PS: I am a newbie to angular 2

Answer Source
You have to import a module in whatever module you want to use components, directives or pipes of the imported module. There is no way around it.

What you can do is to create a module that exports several other modules (like for example the `BrowserModule` that exports `CommonModule`.

  declarations: [CoolComponent, CoolDirective, CoolPipe],
  imports: [MySharedModule1, MySharedModule2],
  exports: [MySharedModule1, MySharedModule2, CoolComponent, CoolDirective, CoolPipe],
export class AllInOneModule {}

  imports: [AllInOneModule]
class MyModule {}

This way you make everything exported by AllInOneModule available to MyModule.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download