我正在使用angular-cli作为Jhipster的客户端,当我尝试构建我的项目时,我在Translate模块上遇到了问题,我试图升级到ngx-translate,但是我仍然遇到同样的问题。
这是我得到的错误:
“ TranslateService”不能分配给“ TranslateService”类型的参数。
shared-common.module.ts:
import { NgModule, Sanitizer } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { TranslateService } from 'ng2-translate';
import { AlertService } from 'ng-jhipster';
import {
CarcheckappSharedLibsModule,
JhiLanguageHelper,
FindLanguageFromKeyPipe,
JhiAlertComponent,
JhiAlertErrorComponent
} from './';
export function alertServiceProvider(sanitizer: Sanitizer,
translateService: TranslateService) {
// set below to true to make alerts look like toast
const isToast = false;
return new AlertService(sanitizer, isToast, translateService);
}
@NgModule({
imports: [
CarcheckappSharedLibsModule
],
declarations: [
FindLanguageFromKeyPipe,
JhiAlertComponent,
JhiAlertErrorComponent
],
providers: [
JhiLanguageHelper,
{
provide: AlertService,
useFactory: alertServiceProvider,
deps: [Sanitizer, TranslateService]
},
Title
],
exports: [
CarcheckappSharedLibsModule,
FindLanguageFromKeyPipe,
JhiAlertComponent,
JhiAlertErrorComponent
]
})
export class CarcheckappSharedCommonModule {}
答案 0 :(得分:0)
您使用了错误的软件包。
import { TranslateService} from '@ngx-translate/core';
AlertService
期望TranslateService
中的@ngx-translate/core
,您不能与另一个交换。
如果要使用ng2-translate
,则必须创建自己的AlertService
。