I don't know how I can read my environment variable. I'm initializing my APP_INITIALIZER here in app.module.browser.ts,
@NgModule({
bootstrap: [AppComponent],
imports: [
BrowserModule,
AppModuleShared,
AppAuthModule
],
declarations: [],
providers: [
{ provide: 'BASE_URL', useFactory: getBaseUrl },
{
provide: APP_INITIALIZER, // <-- HERE
useFactory: configurationServiceFactory,
deps: [ConfigurationService],
multi: true
},
{
provide: HTTP_INTERCEPTORS,
useClass: TokenInterceptor, //AuthInterceptor,
multi: true
}
ConfigurationService,
ErrorLogService
]
After this initialization, I'm having some constant variables. I want to read my environment variable. So I can put this into condition and I can import my module depending my condition like this.
import { AccountsComponent } from "./customerList/components/accounts/accounts.component";
import { AccountsPlusComponent } from "./customerList/components/accounts-plus/accounts-plus.component";
let accountsInjection: any = ENV_VARIABLE ? AccountsComponent : AccountsPlusComponent;
@NgModule({
declarations: [
accountsInjection
],
imports: [
...
NOTE: I don't have app/environments/ folder in my project... (I'm still looking a way to put it)
Edit: I also want to give extra information, I'm using WEBPACK, should I use another method to get my Envarionment variables?