In my angular library (library word is very important here!) I've it :
@NgModule({
imports: [CommonModule],
providers: [
{
provide: APP_INITIALIZER,
deps: [TreatmentDeclaratorServiceSpecificImpl],
useFactory() {
return async () => Promise.resolve();
},
multi: true
},
TreatmentDeclaratorServiceSpecificImpl
]
})
export class TreatmentDeclaratorModule { }
The goal is to force Angular to instanciante TreatmentDeclaratorServiceSpecificImpl, also if application not import the service.
How can I do it with an application which use standalone components? Application is forced to declare all theses classes into his bootstrap function??
The APP_INITIALIZER was transparent for application, I wish this was still the case with standalone components.
Its possible?
Regards
This is how I would do it
And use in AppModule or ApplicationConfig
Maybe take a look at how Router and HttpClient do this.