We need some services in our application right from the start. Therefore we have some providers, that initialize them on startup. This is from the providers section in app.module.ts:
providers: [
{ provide: MAT_DATE_LOCALE, useValue: 'en-US' },
{
provide: APP_INITIALIZER,
useFactory: (service: MetaService) => () => service,
deps: [MetaService],
multi: true
}
],
This worked fine in Angular 9-11. However, after upgrading to Angular 12 and even in a blank Angular 12 project, this seems to break the application.
The service is created though. It's correctly logged using this:
useFactory: (service: MetaService) => () => { console.log(service); return service; },
However, the page comes back as blank white one. No component is rendered, no routing did happen.
There are no errors on the CLI and nothing in the browser's console, just a blank page. When I remove the provider, it seems to work fine.
Did they change, how APP_INITIALIZER works in Angular 12? How to fix or update the code to make it work again? Maybe there's a better way to initialize services on startup anyway?