【问题标题】:AOT compilation - forRoot and other func calls problemsAOT编译——forRoot等func调用问题
【发布时间】:2017-04-15 05:37:15
【问题描述】:

我在尝试编译我的应用程序时收到 "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) 函数调用时会发生这种情况。

如何解决?为什么会这样?我不明白,我认为它是原生 angular 2 函数,它使用配置导入模块。

【问题讨论】:

标签: angular angular2-aot


【解决方案1】:

我收到此错误,提供基于此帖子 https://stackoverflow.com/a/39344889/4956569 的 Angular 的“LOCALE_ID”

已解决为错误消息提示...将其导出为函数...

post 的原始实现(不适用于 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();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-26
    • 1970-01-01
    • 2023-04-02
    • 1970-01-01
    • 1970-01-01
    • 2018-02-14
    • 1970-01-01
    • 2017-03-10
    相关资源
    最近更新 更多