From 07bf7ab040bfcc478a947147935c6191cbff05b0 Mon Sep 17 00:00:00 2001 From: Luca Peruzzo <69015314+luca-peruzzo@users.noreply.github.com> Date: Tue, 17 Dec 2024 00:54:18 +0100 Subject: [PATCH] fix(v19): provide primeng (#17043) --- packages/primeng/src/config/provideprimeng.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/primeng/src/config/provideprimeng.ts b/packages/primeng/src/config/provideprimeng.ts index 58432c6e40b..120cd3a77ce 100644 --- a/packages/primeng/src/config/provideprimeng.ts +++ b/packages/primeng/src/config/provideprimeng.ts @@ -1,4 +1,4 @@ -import { APP_INITIALIZER, EnvironmentProviders, InjectionToken, makeEnvironmentProviders } from '@angular/core'; +import { EnvironmentProviders, inject, InjectionToken, makeEnvironmentProviders, provideAppInitializer } from '@angular/core'; import { PrimeNG, PrimeNGConfigType } from './primeng'; export const PRIME_NG_CONFIG = new InjectionToken('PRIME_NG_CONFIG'); @@ -10,13 +10,11 @@ export function providePrimeNG(...features: PrimeNGConfigType[]): EnvironmentPro multi: false })); - // @todo: use provideAppInitializer in v19 - const initializer = { - provide: APP_INITIALIZER, - useFactory: (PrimeNGConfig: PrimeNG) => () => features?.forEach((feature) => PrimeNGConfig.setConfig(feature)), - deps: [PrimeNG], - multi: true - }; + const initializer = provideAppInitializer(() => { + const PrimeNGConfig = inject(PrimeNG); + features?.forEach((feature) => PrimeNGConfig.setConfig(feature)); + return; + }); return makeEnvironmentProviders([...providers, initializer]); }