Closed ramoncarreras closed 5 years ago
My fault, changing my app.module.ts to this makes translation work:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { NgxWebstorageModule } from 'ngx-webstorage';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { Insomnia } from '@ionic-native/insomnia/ngx';
import { Device } from '@ionic-native/device/ngx';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import { ComponentsModule } from './components/components.module';
import { TranslateLoaderService } from './services/translate-loader/translate-loader.service';
@NgModule({
declarations: [
AppComponent,
],
entryComponents: [],
imports: [
BrowserModule,
IonicModule.forRoot({
backButtonText: '',
backButtonIcon: 'ios-arrow-back',
spinner: 'dots',
refreshingSpinner: 'dots',
loadingSpinner: 'dots',
infiniteLoadingSpinner: 'dots',
}),
NgxWebstorageModule.forRoot({prefix: 'tax-rd', separator: '.'}),
AppRoutingModule,
ComponentsModule,
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: TranslateLoaderService,
},
}),
],
providers: [
SplashScreen,
Insomnia,
Device,
{provide: RouteReuseStrategy, useClass: IonicRouteStrategy},
],
bootstrap: [AppComponent],
})
export class AppModule {
}
Current behavior
When I use http-loader to load translations from my API, my APP crashes with the following error displayed on the console:
"this.textApi.list" is the method I call when I overwrite TranslateLoader::getTranslation()
Minimal reproduction of the problem with instructions
My app.module.ts looks like this:
And, this is my TranslateLoaderService:
Finally, this is my TextApiService...
... and my ClientApiService (only get method is copied to simplify):
Environment
So, I'm doing something wrong or there is a bug on ngx-translate?
Any help will be appreciated. Thanks.