Hey,
I created a shared service to use in all my components/pages.
In this service I do things like testing the network connection etc.
Now I would like to access this functionality in another “regular” provider. For example to test the network to decide where to get my data from.
Basically it works fine, but it creates a new instance of the service instead of using the global one like the components do.
This is how my shared service looks like:
import { Injectable } from '@angular/core';
@Injectable()
export class SharedService {
public hasNetworkConnection : boolean;
constructor() { }
hasNetwork() : boolean {
/* ... */
}
}
And my other provider looks like this:
import { Injectable } from '@angular/core';
import { SharedService } from './sharedservice';
@Injectable()
export class ExampleProvider {
constructor( private sharedService: SharedService ) { }
getData() {
this.sharedService.hasNetwork();
}
}
Is it even possible to use it in another provider?
Or is there any workaround for this?