I have a custom class:
class Global {
public isMobileDevice() {
}
}
So, I want to inject service class inside this method like:
public isMobileDevice(private deviceService: DeviceDetectorService): boolean {
return true;
}
Because I Can not inject this service in constructor like this:
constructor(private deviceService: DeviceDetectorService) {
}
I tried this:
public isMobileDevice(): boolean {
return new DeviceDetectorService();
}
Because I Can not inject this service in constructor like thiswhy????angularonly supports constructor injection.DeviceDetectorServicein each places.DeviceDetectorServiceas static or as Facade