gpt4 book ai didi

angular - ERROR in Error 遇到静态解析符号值

转载 作者:搜寻专家 更新时间:2023-10-30 21:51:22 25 4
gpt4 key购买 nike

我刚刚在 angular-cli 下迁移了我的项目,当我启动它时出现了这个错误:

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:

...
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 }
...

有趣的是,当我评论这一行时,它开始很好,然后取消评论,这一次触发编译没有错误!!!

你有什么想法吗?

谢谢,哔叽。

最佳答案

你需要像这样提取函数:

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

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

另见

关于angular - ERROR in Error 遇到静态解析符号值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43694392/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com