YulePale
YulePale

Reputation: 7706

Angular: can components of an imported module access the services provided in the parent module?

If I have module-A with component-A and module-B with service-B and I import module-A into Module-B, will component-A be able to access service-B?

Upvotes: 1

Views: 526

Answers (1)

Rafi Henig
Rafi Henig

Reputation: 6424

No, when importing module A into B, Module A is accessible by module B but not vice versa.

Although services are accessible to all components declared by a module, it doesn't apply on imported module's components due to the simple fact that regardless of the location where they are used, they are still living in Module A's context where they have no access to Module B's services.

Upvotes: 1

Related Questions