Not able to do component inheritence

Discussão em 'Angular' iniciado por Yogesh, Março 30, 2025.

  1. Yogesh

    Yogesh Guest

    I am trying to do component inheritance in Angular 17 and cannot figure why its giving me an error. Here is my code structure:

    export class ParentComponent {
    constructor(public httpService: myCustomHttpService)
    {
    }
    }


    export class ChildComponent extends ParentComponent {
    constructor() {
    super(httpService);
    }
    }


    I get an error "Cannot find name 'httpService'. Did you mean the instance member 'this.httpService'?". Then if I add this.httpService to super(). I get an error "'super' must be called before accessing 'this' in the constructor of a derived class."

    What am I missing?

    Continue reading...

Compartilhe esta Página