角度未捕获错误:无法解析

时间:2019-10-11 06:54:56

标签: angular angular6 angular8

我正在扩展https://github.com/DanielYKPan/date-time-picker/库中的一个类

我的课是:

export class DefaultIntl extends OwlDateTimeIntl {
  cancelBtnLabel: '';
  constructor(
    private translateService: TranslationService,
  ) {
    super();
    this.translateService
      .translateKey(CANCEL_BTN')
      .subscribe(message => {
        console.log('Message:' + message);
        this.cancelBtnLabel = message;
      });
  }
}

还有我要在库中扩展的类:

import { Subject } from 'rxjs';
export declare class OwlDateTimeIntl {
    readonly changes: Subject<void>;
    upSecondLabel: string;
    downSecondLabel: string;
    upMinuteLabel: string;
    downMinuteLabel: string;
    upHourLabel: string;
    downHourLabel: string;
    prevMonthLabel: string;
    nextMonthLabel: string;
    prevYearLabel: string;
    nextYearLabel: string;
    prevMultiYearLabel: string;
    nextMultiYearLabel: string;
    switchToMonthViewLabel: string;
    switchToMultiYearViewLabel: string;
    cancelBtnLabel: string;
    setBtnLabel: string;
    rangeFromLabel: string;
    rangeToLabel: string;
    hour12AMLabel: string;
    hour12PMLabel: string;
}

有了这个,我得到了错误:

  

未捕获的错误:无法解析DefaultIntl​​的所有参数

我的翻译服务是:

import { Component, Input, Output, EventEmitter } from '@angular/core';
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
import { TranslateService } from '@ngx-translate/core';

@Injectable()
export class TranslationService {
    constructor(private translate: TranslateService) {
    }
    translateKey(key: string, param?: any){
          return this.translate.get(key, param);
    }
}

我该如何解决这个问题?

0 个答案:

没有答案