MOBILE-3565 core: Prepare translate and http libraries
parent
1241be46ec
commit
6fc97ed30f
|
@ -15,11 +15,13 @@
|
||||||
import { NgModule, Injector } from '@angular/core';
|
import { NgModule, Injector } from '@angular/core';
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { RouteReuseStrategy } from '@angular/router';
|
import { RouteReuseStrategy } from '@angular/router';
|
||||||
|
import { HttpClient, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||||
|
|
||||||
import { IonicModule, IonicRouteStrategy, Platform } from '@ionic/angular';
|
import { IonicModule, IonicRouteStrategy, Platform } from '@ionic/angular';
|
||||||
|
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
|
import { CoreInterceptor } from '@classes/interceptor';
|
||||||
|
|
||||||
// Import core services.
|
// Import core services.
|
||||||
import { CoreAppProvider } from '@services/app';
|
import { CoreAppProvider } from '@services/app';
|
||||||
|
@ -49,23 +51,41 @@ import { CoreTimeUtilsProvider } from '@services/utils/time';
|
||||||
import { CoreUrlUtilsProvider } from '@services/utils/url';
|
import { CoreUrlUtilsProvider } from '@services/utils/url';
|
||||||
import { CoreUtilsProvider } from '@services/utils/utils';
|
import { CoreUtilsProvider } from '@services/utils/utils';
|
||||||
|
|
||||||
|
// Import core modules.
|
||||||
import { CoreEmulatorModule } from '@core/emulator/emulator.module';
|
import { CoreEmulatorModule } from '@core/emulator/emulator.module';
|
||||||
import { CoreLoginModule } from '@core/login/login.module';
|
import { CoreLoginModule } from '@core/login/login.module';
|
||||||
|
|
||||||
import { setSingletonsInjector } from '@singletons/core.singletons';
|
import { setSingletonsInjector } from '@singletons/core.singletons';
|
||||||
|
|
||||||
|
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
|
||||||
|
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
|
||||||
|
|
||||||
|
// For translate loader. AoT requires an exported function for factories.
|
||||||
|
export function createTranslateLoader(http: HttpClient): TranslateHttpLoader {
|
||||||
|
return new TranslateHttpLoader(http, './assets/lang/', '.json');
|
||||||
|
}
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [AppComponent],
|
declarations: [AppComponent],
|
||||||
entryComponents: [],
|
entryComponents: [],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
IonicModule.forRoot(),
|
IonicModule.forRoot(),
|
||||||
|
HttpClientModule, // HttpClient is used to make JSON requests. It fails for HEAD requests because there is no content.
|
||||||
|
TranslateModule.forRoot({
|
||||||
|
loader: {
|
||||||
|
provide: TranslateLoader,
|
||||||
|
useFactory: (createTranslateLoader),
|
||||||
|
deps: [HttpClient],
|
||||||
|
},
|
||||||
|
}),
|
||||||
AppRoutingModule,
|
AppRoutingModule,
|
||||||
CoreEmulatorModule,
|
CoreEmulatorModule,
|
||||||
CoreLoginModule,
|
CoreLoginModule,
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
|
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
|
||||||
|
{ provide: HTTP_INTERCEPTORS, useClass: CoreInterceptor, multi: true },
|
||||||
CoreAppProvider,
|
CoreAppProvider,
|
||||||
CoreConfigProvider,
|
CoreConfigProvider,
|
||||||
CoreCronDelegate,
|
CoreCronDelegate,
|
||||||
|
@ -96,8 +116,8 @@ import { setSingletonsInjector } from '@singletons/core.singletons';
|
||||||
bootstrap: [AppComponent],
|
bootstrap: [AppComponent],
|
||||||
})
|
})
|
||||||
export class AppModule {
|
export class AppModule {
|
||||||
constructor(injector: Injector, platform: Platform) {
|
|
||||||
|
|
||||||
|
constructor(injector: Injector, platform: Platform) {
|
||||||
// Set the injector.
|
// Set the injector.
|
||||||
setSingletonsInjector(injector);
|
setSingletonsInjector(injector);
|
||||||
|
|
||||||
|
@ -133,4 +153,5 @@ export class AppModule {
|
||||||
// Execute the init processes.
|
// Execute the init processes.
|
||||||
CoreInit.instance.executeInitProcesses();
|
CoreInit.instance.executeInitProcesses();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue