Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Angular Translate arrow function factory

When I import TranslateModule using this code:

TranslateModule.forRoot({
    loader: {
        provide: TranslateLoader,
        useFactory: HttpLoaderFactory,
        deps: [HttpClient]
    }
})

where

export function HttpLoaderFactory(http: HttpClient) {
    return new TranslateHttpLoader(http, "./assets/i18n/", ".json");
}

everything works but if I use an arrow function:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

export const HttpLoaderFactory = (http: HttpClient) => new TranslateHttpLoader(http, "./assets/i18n/", ".json");

I got this error:

Uncaught ReferenceError: Cannot access 'HttpLoaderFactory' before initialization
    at Module.HttpLoaderFactory (app.component.ts:18:26)
    at Module.10617 (core-components.module.ts:18:29)
    at __webpack_require__ (bootstrap:19:1)
    at Module.36747 (app.component.ts:18:26)
    at __webpack_require__ (bootstrap:19:1)
    at Module.14431 (environment.ts:33:68)
    at __webpack_require__ (bootstrap:19:1)
    at __webpack_exec__ (.*$:292:1)
    at .*$:292:1
    at Function.__webpack_require__.O (chunk loaded:23:1)

Why is this happening?

Thanks

>Solution :

i think this simply isn’t supported in angular AOT.

Here is a list of supported features and the issue mentioning it

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading