I have a parent service which has some dependencies like
@Injectable()
export class ParentService{
constructor(private http:Http, private customService:CustomService){}
}
and I want to extend the service
@Injectable()
export class ChildService extends ParentService{
constructor (){
super(??) <= typescript now asking to enter two parameters according to ParentServie's constructor
}
}
Edit-----------------
@Injectable()
export class ParentService{
constructor(private http:Http, private customService:CustomService){}
get(){this.http.get(...)}
}
@Injectable()
export class ChildService extends ParentService{
constructor (private http:Http, private customService:CustomService){
super(http, customService)
}
}
Then I can use in components?
export class Cmp {
constructor(private childService:ChildService){
this.childService.get()
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…