At the moment, I have been implementing a common approach to load data from a JSON file into my Angular 5 application. This allows me to easily inject this content into my components. The process I am following is well documented in the Runtime configuration section.
To achieve this, I'm utilizing an npm package that requires initialization in my app.module.ts file.
@NgModule({
declarations: [
AppComponent
],
imports: [
/* .... */
[MsalModule.forRoot({
clientID: "...",
authority: "...",
redirectUri: <I need the value here from the JSON file>
})]
],
providers: [
ConfigService,
{
provide: APP_INITIALIZER,
useFactory: (config: ConfigService) => () => config.load(),
deps: [ConfigService],
multi: true
}
]
bootstrap: [AppComponent]
})
export class AppModule { }
Although I am aware that Angular-CLI supports different environment files, the dynamic nature of the JSON file makes it essential for me to fetch its values post-build rather than relying on pre-defined configurations.
Is there a feasible way to access a value from the JSON file directly within the NgModule declaration where it's needed?