I have a service for sharing data between components and other services. I'm injecting it into components and services with angular's DI. The service stores some data in its properties (non-statically). I also user a ComponentResolver to dynamically create and load components and then destroy them. The problem is ... if i inject such a service in a component using simply:
constructor(private myService: MyDataService) { ... }
A new instance of this server is injected each time and the data is lost. I could store the data statically, but then there are observers that subscribe to this data. Long story short - too many things to refactor into static variables. Is there some sort of way to tell angular's DI to only create one instance of this service and share it in every single injection?