Reputation: 1417
I am currently creating an abstract class that every service can inherit from. I try to instantiate the HttpClient in the abstract class but an argument is needed. Which one (what type, ...)?
I don't want to repeat it in constructor of inherited classes. That's why I am trying to do so.
import { HttpClient } from '@angular/common/http';
export abstract class GenericService<T> {
//... code ...
constructor() {
this._http = new HttpClient(); // Argument needed ?
}
//... code ...
}
Upvotes: 2
Views: 531
Reputation: 1148
Try this
import { HttpClient } from '@angular/common/http';
export abstract class GenericService<T> {
//... code ...
constructor(private _http: HttpClient) {}
//... code ...
}
Upvotes: 2