When it comes to Angular 2+, providers are typically registered in the following manner:
// Using the @NgModule decorator and its metadata
@NgModule({
declarations: [...],
imports: [...],
providers: [<PROVIDERS GO HERE>],
bootstrap: [...]
})
export class AppModule { }
However, I am interested in setting up application-scoped providers separately from this declaration location.
My current situation involves utilizing NSwag to automatically create service clients for my entire Web API, and I wish to dynamically add these generated service clients as providers. The challenge lies in finding a way to accomplish this task, especially given that @NgModule
is an attribute that applies to the AppModule
class itself.
Do you happen to know if achieving this separation of concern is actually feasible?