how to extend service with dependencies in angular 2

前端 未结 3 1405
野的像风
野的像风 2020-12-14 06:48

I have a parent service which has some dependencies like

@Injectable()
export class ParentService{
  constructor(private http:Http, private customService:Cus         


        
3条回答
  •  不知归路
    2020-12-14 07:22

    The parameters of the super class need to be repeated and passed to the super call:

    @Injectable()
    export class ChildService extends ParentService{
      constructor (http:Http, customService:CustomService){
        super(http, customService);
      }
    }
    

    There are some "hacks" to work around like Inheritance and dependency injection

提交回复
热议问题