2016-11-30 48 views
3

嘗試編譯我的應用程序時出現"Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol DeclarantModule"錯誤。當模塊有forRootStoreModule.provideStore(rootReducer)函數調用時會發生這種情況。AOT編譯 - forRoot和其他函數調用問題

如何解決?爲什麼發生這種情況?我不明白,我認爲它是原生的角2功能,導入模塊與配置。

+0

現在,好像你不能配置模塊並使用AOT。 – lexigren

+0

嘗試恢復到角度版本2.3.1,如下所述:http://stackoverflow.com/questions/41463860/how-to-use-routermodule-forroot-in-angular2-compiler-cli-ngc-command/41480174#41480174 –

回答

0

我收到此錯誤提供角度的「LOCALE_ID」基於這個帖子https://stackoverflow.com/a/39344889/4956569

解決了作爲錯誤信息建議...導出爲一個功能...

後的最初實現(不工作AOT編譯)

{ 
    provide: LOCALE_ID, 
    deps: [SettingsService],  //some service handling global settings 
    useFactory: (settingsService) => settingsService.getLanguage() //returns locale string 
} 

我的固定實現(與AOT編譯工作)

{ 
    provide: LOCALE_ID, 
    deps: [SettingsService],  //some service handling global settings 
    useFactory: localeIdFactory 
} 
export function localeIdFactory(settingsService: SettingsService) { 
    return settings.getLanguage(); 
}