Hi All,
Any one can explain why my service instance is created only once , i have implemented eagar and lazy loading with netesd routing , i have injected the service all the components but still its taking the same instance . i have given my stackblitz link below kindly anyone have a look .
i want to check why lazy-loaded module taking same service instance.
https://stackblitz.com/edit/angular-drtk4e

Karthikeyan KPosted Jan 3, 2019, 5:32 AM
Karthikeyan KPosted Jan 3, 2019, 4:28 AM
Muthu KumarPosted Jan 3, 2019, 4:14 AM
https://stackoverflow.com/questions/39672816/can-lazy-loaded-modules-share-the-same-instance-of-a-service-provided-by-their-p
Muthu KumarPosted Jan 3, 2019, 4:13 AM
I can't open that link need to login. Can you explain which you want to know?.
Karthikeyan KPosted Jan 3, 2019, 4:03 AM
Muthu KumarPosted Jan 3, 2019, 3:48 AM
If you imported your service file in app module file providers block. Then it will create only one instance.
If you imported your service file in every component like following,
For reference i have changed your stackblitz and mentioned screenshot,
But best practices is using app module for import services.