Core: Error encountered resolving symbol values statically

Created on 2 May 2017  路  3Comments  路  Source: ngx-translate/core

I'm submitting a ...

[x] bug report => check the FAQ and search github for a similar issue or PR before submitting
[ ] support request => check the FAQ and search github for a similar issue before submitting
[ ] feature request

Current behavior

J'ai pist茅 cette erreur et je me suis apper莽u qu'elle 茅tait caus茅 par le module de traduction, une fois ce code comment茅 tout va bien

TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: (http: Http) => {
          return new TranslateHttpLoader(http);
        },
        deps: [Http]
      }
    }),

Voici l'erreur en d茅tail, qui dispara卯t si je commente le code ci dessus, et que je relance le "ng serve"

> ng serve
** NG Live Development Server is running on http://localhost:4200 **
 64% building modules 541/594 modules 53 active ..._modules/inherits/inherits_browser.jswebpack: wait until bundle finished: /
Hash: 3b4b4eb502b9a5d641e2                                                              
Time: 31222ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 158 kB {4} [initial] [rendered]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 95.4 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 72.2 kB {4} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 4.19 MB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]

ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 33:21 in the original .ts file), resolving symbol AppModule in /home/pixocode/projects/noostache/ng-mastodon/src/app/app.module.ts
webpack: Failed to compile.

Si je commente le code sans relancer le "ng serve" l'erreur devient celle-ci

webpack: Compiling...
Hash: faa9bed6c4ee1a213414                                                         
Time: 1561ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 158 kB {4} [initial]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 95.4 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 72.2 kB {4} [initial]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 4.19 MB [initial]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry]

ERROR in Cannot read property 'length' of undefined
webpack: Failed to compile.

Please tell us about your environment:

"@angular/core": "^4.0.0",
"@angular/cli": "1.0.0",
"@angular/compiler-cli": "^4.0.0",
"@ngx-translate/core": "^6.0.1",
"@ngx-translate/http-loader": "0.0.3",

Browser: all

Most helpful comment

English please...

All 3 comments

This is not an error from the library but from your code.
useFactory requires an exported function, not an anonymous inline function.
Like explained in the documentation:

// AoT requires an exported function for factories
export function HttpLoaderFactory(http: Http) {
    return new TranslateHttpLoader(http);
}

@NgModule({
    imports: [
        BrowserModule,
        HttpModule,
        TranslateModule.forRoot({
            loader: {
                provide: TranslateLoader,
                useFactory: HttpLoaderFactory,
                deps: [Http]
            }
        })
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }

O_o ah ok, d茅sol茅 je comprenais pas la logique de ce besoin... Merci :)

English please...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

louisdoe picture louisdoe  路  3Comments

jvquarck picture jvquarck  路  3Comments

jstoup111 picture jstoup111  路  4Comments

IterationCorp picture IterationCorp  路  3Comments

Snap252 picture Snap252  路  3Comments