My goal is to simplify the declaration of a provider by using a static function in this way:
const provider = MyModule.configureProvider();
@NgModule({
bootstrap: [AppComponent],
declarations: [AppComponent],
imports: [
...
],
providers: [
provider,
...
],
})
Unfortunately, I encountered an issue with AOT where the provider was missing.
However, when I use the following approach, everything works correctly:
const providers = [{provide : myToken, useValue: "value"}];
@NgModule({
bootstrap: [AppComponent],
declarations: [AppComponent],
imports: [
...
],
providers: [
provider,
...
],
})