I am facing an issue with my 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")
}
}
While working in Angular2, I have noticed that I need to include the constructor of BaseService and MediaService, even though MediaService inherits from BaseService.
I am trying to figure out a way to inject Angular2 into the BaseService without having it in the constructor of MediaService.
Currently, all the classes are extending the BaseService and depending on the ApiService, even though they inherit from the BaseService.