错误:this.currentLoader.getTranslation(...)。pipe不是函数

时间:2019-02-26 05:57:02

标签: angular ngx-translate angular-transitions

我将ngx-translate用于其中一个有角项目。当我尝试从http发布请求加载翻译数据时,它失败了。代码如下:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule, Injectable } from '@angular/core';
import { AppComponent } from './app.component';
import {HttpClient, HttpClientModule} from '@angular/common/http';
import {TranslateModule, TranslateLoader} from '@ngx-translate/core';

@Injectable({
 providedIn: 'root'
})
export class TranslationService {
  constructor(private http: HttpClient) { }
  getTranslation() {
     return this.http.post('https://dev- 
     api.chilindo.com/api/Language/v1/PageText', { 'name': 'Master', 
     language: 'en', domain:'th' }).subscribe((resp:any)=>{
  return resp;
})
}
}

@NgModule({
 declarations: [
   AppComponent
 ],
 imports: [
    BrowserModule,
    HttpClientModule,
    TranslateModule.forRoot({
  loader: {
    provide: TranslateLoader,
    useClass : TranslationService,
    deps: [HttpClient]
  }
})
],
 providers: [],
 bootstrap: [AppComponent]
 })
export class AppModule { }

这是相同的https://stackblitz.com/edit/github-x4rjpw

0 个答案:

没有答案