lmeijdam/angular-umd-dynamic-example

Sharing data between two modules.

Closed this issue · 3 comments

Hi,

First of all - thank you for publishing this repo, it has been a great insight for learning dynamic module loading.

Playing around with this, I quickly became aware of the lack of 'connection' between two modules, lets call them ModuleA and ModuleB. If I need them two modules to share data or make calls to a common function (i.e: with a service) does anybody know how I could do that?

Cheers

Well, most of the solution was written with the mindset that 2 (or more) modules could live independently without knowledge of each other. I think in regards to sharing data you need to have a service in both modules to retrieve/send data to/from an API.

I did try a service, but they are not shared. The injector seems to create two separate instances of the service instead of using the same one.

yeah , that I what I mean! :) not having one service in both modules, but an instance of a service (so 2 in total) to retrieve/write data from the backend