I have three classes:
@Injectable()
export class ApiService {
constructor(public http: Http) {}
get(url: string) {
return http.get(url);
}
}
@Injectable()
export abstract class BaseService {
constructor(protected serv: ApiService) {}
}
@Injectable()
export class MediaService extends BaseService {
// Why do we need this?
constructor(s: ApiService) {
super(s)
}
makeCall() {
this.serv.get("http://www.example.com/get_data")
}
}
In Angular2 I have to include for both the constructor of BaseService and MediaService even though MediaService inherits the BaseService.
How can I get Angular2 injection into the BaseService without having it in the constructor of MediaService?
Now I have all the classes extending the BaseService depending on the ApiService while they inherit from the BaseService.