0

I'm a bit confused about the application instantiation hierarchy, especially for providers. So basically you do the following in app.module.ts

import { myService} from '../providers/myService/myService';

and add it to the

@NgModule collection
    providers:[
        bla bla,
        myService
    ]

Now if I import and instantiate MyService in the app.components.ts does that make it a singleton for the whole app?

Every time I have wanted to use it on a page I have done the import and page constructor thing (e.g. myServ: myService)...but does that create a new instance or use the one created from app.components.ts.

I would love an explanation of the life-cycle of the components so the I know what I'm doing (well, as best as possible!!)

Tomislav Stankovic
  • 3,080
  • 17
  • 35
  • 42
SuperRoo
  • 87
  • 1
  • 7

1 Answers1

1

Injected Services in Ionic2+ are indeed Singletons and Ionic will instantiate and configure them during framework initialization.

Cody Caughlan
  • 32,456
  • 5
  • 63
  • 68