Angular-在派生类的构造函数中访问“ this”之前,必须先调用“ super”

时间:2019-01-24 10:20:14

标签: angular typescript

我有一个TypeIdentifierService类来扩展另一个类, 在TypeIdentifierService类中,我注入了ConfigService,并在super方法中使用了此服务,但它向我显示了此错误

  在访问a的构造函数中的'this'之前,必须先调用

'super'   派生类。

@Injectable()
export class DataService<T> {

    constructor(
        @Inject('API_BASE_URL') protected url: string,
        protected httpClient: HttpClient,
        protected responseHandler: HttpResponseHandler
    ) { }
}

@Injectable()
export class TypeIdentifierService extends DataService<Dictionary> {

    constructor(httpClient: HttpClient, responseHandler: HttpResponseHandler, private config: ConfigService) {
        super(`${this.config.getSettings('environment.serviceBaseUrl.sp')}/typeIdentifiers`, httpClient, responseHandler);
    }

}

0 个答案:

没有答案