ERROR中的ERROR遇到静态解析符号值的错误 [英] ERROR in Error encountered resolving symbol values statically

查看:108
本文介绍了ERROR中的ERROR遇到静态解析符号值的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在angular-cli下迁移了我的项目,并且在启动该项目时遇到此错误:

I just migrated my project under angular-cli and I'm getting this error when I start it:

ERROR in Error遇到静态解析符号值的情况. 不支持函数调用.考虑更换功能或 lambda并引用了导出的函数(在代码中的位置63:45 原始.ts文件),在其中解析符号AppModule C:/Data/Private/Innovation/EV/ev-dashboard/src/app/app.module.ts

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 63:45 in the original .ts file), resolving symbol AppModule in C:/Data/Private/Innovation/EV/ev-dashboard/src/app/app.module.ts

对应于以下app.module.ts中的APP_INITIALIZER:

Which corresponds to the APP_INITIALIZER below in app.module.ts:

...
providers: [ // expose our Services and Providers into Angular's dependency injection
    APP_PROVIDERS,
    ConfigService,
    { provide: APP_INITIALIZER, useFactory: (config: ConfigService) => () => config.load(), deps: [ConfigService], multi: true }
...

有趣的是,当我注释此行时,它会很好地启动,然后取消注释,这一次将触发编译而没有错误!!!

What is funny is that when I comment this line, it starts well and uncomment it afterward which triggers a compilation without error this time!!!

你有个主意吗?

谢谢, 塞尔吉.

推荐答案

您需要提取以下函数:

export function configFactory(config: ConfigService) {
  return () => config.load()
}

...
providers: [{ 
  provide: APP_INITIALIZER, 
  useFactory: configFactory, 
  deps: [ConfigService], 
  multi: true 
}

另请参见

Angular4 APP_INITIALIZER不会延迟初始化

这篇关于ERROR中的ERROR遇到静态解析符号值的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆