I am trying to do some kind of inheritance over some services that I have. I don't really know if it is a good practice or not, anyway I would really like to refactor all the entire app getting new approachs.
Anyways, that's what I have
...............................
@Injectable()
export class ApiBaseService {
...............................
constructor(url : string, _logger : LoggerService) {
...............................
}
...............................
And a child class
...............................
@Injectable()
export class ApiWhatEverService extends ApiBaseService {
constructor(private _http: Http) {
super(environment.apiUrl);
}
...............................
}
The point here is that constructors don't match due to DI related with LoggerService
So my thoughts here is trying to inject the LoggerService in any other way like using injector of angular, but it fails
...............................
@Injectable()
export class ApiBaseService {
apiUrl;
_logger : LoggerService;
...............................
constructor(url : string) {
...............................
let injector = ReflectiveInjector.resolveAndCreate([
LoggerService
]);
this._logger = injector.get(LoggerService);
//IT DOESN'T GET ALL THE METHOD ASSOCIATED TO LoggerService
...............................
}
...............................
}
I would appreciate if someone could help or guide me with that.
Many thanks in advance