Files
Younes Jaaidi 5ce10264a4 fix(migrations): fix provide-initializer migration when using useFactory (#58518)
Priori to this commit, initializer functions with dependencies were not migrated correctly.
With this commit, the function is executed in a injection context to allow the usage of `inject`.

PR Close #58518
2024-11-21 20:59:35 +00:00
..

Replace APP_INITIALIZER, ENVIRONMENT_INITIALIZER, and PLATFORM_INITIALIZER with provider functions

Replaces APP_INITIALIZER, ENVIRONMENT_INITIALIZER, and PLATFORM_INITIALIZER with their respective provider functions: provideAppInitializer, provideEnvironmentInitializer, and providePlatformInitializer.

Before

import {APP_INITIALIZER} from '@angular/core';

const providers = [
  {
    provide: APP_INITIALIZER,
    useValue: () => { console.log('hello'); },
    multi: true,
  }
];

After

import {provideAppInitializer} from '@angular/core';

const providers = [provideAppInitializer(() => { console.log('hello'); })];