angular 19 - APP_INITIALIZER deprecation

Discussão em 'Angular' iniciado por Igor, Novembro 20, 2024.

  1. Igor

    Igor Guest

    I am trying to upgrade from angular 18 to 19. Automatic migration changed the following code

    providers: [
    {
    provide: APP_INITIALIZER,
    useFactory: initializeApp1,
    deps: [AuthService],
    multi: true
    },
    ]


    to this:

    providers: [
    provideAppInitializer(initializeApp1(inject(AuthService)))
    ]


    however when I run the code I am getting error Uncaught RuntimeError: NG0203: inject() must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with runInInjectionContext. Find more at https://angular.dev/errors/NG0203

    I am pretty stuck as to how to solve this error, could you help me?

    thanks a lot

    Continue reading...

Compartilhe esta Página