Max Karpovets Max Karpovets - 1 year ago 80
TypeScript Question

Where a should inject service, which should be visible in all app? (angular2)

I want to create

. And I want to have possibility to call it from all application?

Where I should inject it in SharedModule (module which exports all reusable modules) or in AppModule ( main module of my application)


providers: [
// Here?

Answer Source

It doesn't matter if you add it to the AppModule directly or to a feature module as long as the module is not lazy loaded.

Lazy loaded modules have their own root scope and providers added there are only visible to the lazy loaded module.

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