Dependency Injection on a Popover


#1

Hi all,

I have an authentication service which I inject in App.ts so I only have one instance of this service throughout my app.

Injecting this service into Page components works as expected but when I inject the service into a popover component, I am getting a new instance of my authentication service.

Can someone please explain to me why this is happening and is there any workarounds?

Niall


#2

Hi,

Just to make it more clear would you provide a sample or snippet of the issue.


#3

Hello,

Thanks for your reply.

When I have a chance, I will create a simple app to demonstrate but essentially it seems when you inject a service into a popover, a new instance of that service is created. If I treat the popover like a normal component and push it onto the Navigation Controller, a new instance of the service is not created.

Again, when I have more time, I will create an example.

Niall


#4

This problem no longer occurs with ionic 2 rc0. Providers are now truly singletons :slight_smile:


#5

I am having this problem in RC4. Is there some trick to get dependancies into a page passed into a popover?