角度:收集的元数据包含将在运行时报告的错误:不支持Lambda [英] Angular: Metadata collected contains an error that will be reported at runtime: Lambda not supported
本文介绍了角度:收集的元数据包含将在运行时报告的错误:不支持Lambda的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Angular应用中,我试图使用工厂提供商在我的模块中:
In my Angular app, I'm trying to use a factory provider in my module:
export function getMyFactory(): () => Window {
return () => window;
}
@NgModule({
providers: [
{ provide: WindowRef, useFactory: getMyFactory() },
],
})
export class MyModule {}
但这失败了:
为导出的符号"MyModule"生成的元数据遇到错误:
Error encountered in metadata generated for exported symbol 'MyModule':
收集的元数据包含将在运行时报告的错误:不支持Lambda
Metadata collected contains an error that will be reported at runtime: Lambda not supported
推荐答案
我在GitHub的一个线程上发现了一个简单的解决方案:发布haochi
I've found an easy solution reported on a thread from GitHub: Arrow lambda not supported in static function posted by haochi
解决方案基本上是:
将结果分配给变量,然后返回变量
assigning the result to a variable, then return the variable
因此,就我而言,我已解决了以下问题:
So in my case, I've resolved by replacing:
export function getMyFactory(): () => Window {
return () => window;
}
具有:
export function getMyFactory(): () => Window {
const res = () => window;
return res;
}
这篇关于角度:收集的元数据包含将在运行时报告的错误:不支持Lambda的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文