Angular, how to use Service inside ApplicationConfig?

Discussão em 'Angular' iniciado por Maksat Madeniyetov, Novembro 13, 2024.

  1. How to use Service inside ApplicationConfig?

    export const appConfig: ApplicationConfig = {
    providers: [
    provideRouter(appRoutes),
    provideTransloco({
    config: {
    availableLangs: ['en', 'ru', 'kk'],
    defaultLang: LanguageService.getDefaultLanguage(),
    reRenderOnLangChange: true,
    prodMode: !isDevMode(),
    },
    loader: TranslocoHttpLoader,
    }),
    ],
    };


    Here, I want to use LanguageService

    I used:

    1. defaultLang: (new LanguageService).getDefaultLanguage(),
    2. defaultLang: inject(LanguageService).getDefaultLanguage(),

    All of them shows injection context error So, is it possible to use Service inside ApplicationConfig?

    Continue reading...

Compartilhe esta Página