mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
5ce10264a4
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
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'); })];