#Data from service in app module?

6 messages · Page 1 of 1 (latest)

pearl venture
#

Hey all 👋

I'd like to get a configuration from a backend server via a service and provide it to a module in my imports at the top level app module. I'm not sure if this can be done with an app initializer or something or if I should consider a different approach.

e.g.

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        ConfigService,
        DependentModule.forRoot('', somethingFromConfigService),
    ],
    providers: [ ],
    bootstrap: [AppComponent]
})
export class AppModule { }
chrome fractal
#

you can call the api in your main.ts

#

and provide it in the bootstrap method

pearl venture
#

thank you!

round shoal
#

Also, modules are pretty much obsolete since Angular 14. It's time to move on...