I am using ngx-translate and ngx-translate/http-loader for translating my ionic/angular project. I have this code inside app.module.ts imports:
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (createTranslateLoader),
deps: [HttpBackend]
}
})
and this loader function in the same file:
export function createTranslateLoader(handler: HttpBackend) {
const http = new HttpClient(handler);
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}
This gives me opportunity to use this kind of translation syntac inside component's html : {{ 'TEXT' | translate }} , I also can write something like that to translate inside component's ts file : var text = this.translateService.instant("TEXT");
Now I want to use translateService.instant inside service generated by command "ng generate s" I tried it but it doesn't work, it returns "TEXT" itself. So what is the problem?