I am working on an Ionic 2 TypeScript project. When the application starts, I enter the service through the constructor.
@App({ providers: [ MyService ] }) export class MyApp { constructor( private instance1 : MyService ){} }
And in another class I use
let injector = Injector.resolveAndCreate ( [ MyService ] ); let instance2 = injector .get( MyService );
I get two different instances of the variables instance1 and instance2.
Is there any possible way to make them a single instance using the built-in injector and constructor
angularjs dependency-injection angular typescript ionic-framework
tymspy
source share