blob: 074811c3d51f8eb24b55efce87ff0754cee0f91f [file] [log] [blame]
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { HttpModule, Http } from '@angular/http';
// Angular core modules
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule, APP_INITIALIZER } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';
// Routes
import { AppRoutingModule } from './app-routing.module';
// Modules
import { AppComponent } from './app.component';
import { HttpServiceModule } from '@shared/asyncServices/http/http.module';
import { UtilityModule } from '@shared/utility';
//Feature Modules
import { ContactsModule } from '@pages/contacts/contacts.module';
// Store
import { reducers } from '@shared/store';
// Effects
import { ContactsEffects } from '@shared/store/effects/contacts.effect';
import { AngularFontAwesomeModule } from 'angular-font-awesome';
// Guards
import { AuthGuard } from '@shared/guards/auth.guard';
import { CanDeactivateGuard } from '@shared/guards/canDeactivate.guard';
// Services
import { ConfigService } from './app-config.service';
// Third party libraries
import { StoreModule } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { SimpleNotificationsModule } from 'angular2-notifications';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { environment } from 'environments/environment';
import { ContainersModule } from '@shared/containers';
import { ToastrModule } from 'ngx-toastr';
/**
* Calling functions or calling new is not supported in metadata when using AoT.
* The work-around is to introduce an exported function.
*
* The reason for this limitation is that the AoT compiler needs to generate the code that calls the factory
* and there is no way to import a lambda from a module, you can only import an exported symbol.
*/
export function configServiceFactory(config: ConfigService) {
return () => config.load();
}
@NgModule({
declarations: [AppComponent],
imports: [
// Angular core dependencies
BrowserModule,
BrowserAnimationsModule,
FormsModule,
HttpModule,
HttpClientModule,
CommonModule,
// Third party modules
AngularFontAwesomeModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (http: HttpClient) => new TranslateHttpLoader(http, 'i18n/', '.json'),
deps: [HttpClient],
},
}),
SimpleNotificationsModule.forRoot(),
ToastrModule.forRoot(),
// App custom dependencies
HttpServiceModule.forRoot(),
UtilityModule.forRoot(),
// EffectsModule.forRoot([ProductsEffects]),
EffectsModule.forRoot([ContactsEffects]),
StoreModule.forRoot(reducers),
StoreDevtoolsModule.instrument({
maxAge: 25,
logOnly: environment.production,
}),
ContainersModule,
ContactsModule,
AppRoutingModule,
],
providers: [
AuthGuard,
CanDeactivateGuard,
ConfigService,
{
provide: APP_INITIALIZER,
useFactory: configServiceFactory,
deps: [ConfigService],
multi: true,
},
],
bootstrap: [AppComponent],
})
export class AppModule {}