我根据文档在项目中添加了ng-translate,但仍然有错误
//import
import {TranslateLoader, TranslateModule, TranslateService} from '@ngx-translate/core';
//also provides
providers: [
{provide: LOCALE_ID, useValue: 'en-US'},
BaseRequestOptions,
{ provide: HTTP_INTERCEPTORS, useClass: TokenInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: CommonInterceptor, multi: true },
NGXLogger,
TranslateService
],
//and
export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http);
}
答案 0 :(得分:0)
确保已在app.module.ts
的imports块中添加了代码段
例如:
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
// configure the imports
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: HttpLoaderFactory,
deps: [HttpClient]
}
})
],
providers: [],
bootstrap: [AppComponent]
});