Angular 装饰器不支持函数表达式,将函数表达式更改为导出函数。
我试图在我当前的项目中启用angularivy,而在ng构建时,我遇到了这个错误Angular 装饰器不支持函数表达式,将函数表达式更改为导出函数。,angular,angular-ivy,Angular,Angular Ivy,我试图在我当前的项目中启用angularivy,而在ng构建时,我遇到了这个错误 ERROR in src\app\app.module.ts(172,19): Error during template compile of 'AppModule' Function expressions are not supported in decorators Consider changing the function expression into an exported functi
ERROR in src\app\app.module.ts(172,19): Error during template compile of 'AppModule'
Function expressions are not supported in decorators
Consider changing the function expression into an exported function.
src/app/home/home.component.ts(95,4): error TS2554: Expected 2 arguments, but got 1.
src/app/home/home.component.ts(96,4): error TS2554: Expected 2 arguments, but got 1.
node_modules/ngx-bootstrap/timepicker/models/index.d.ts(3,22): error TS2307: Cannot find module '@angular/core/src/type'.
src/app/nomina/solicitudes/vacaciones/vacaciones.component.ts(56,4): error TS2554: Expected 2 arguments, but got 1.
我检查了一些建议,比如在导出中创建函数并再次使用它来解决问题,但错误并没有得到解决,反而发生了变化
],
exports: [],
entryComponents: [],
providers: [
AuthGuard,
{ provide: LOCALE_ID, useValue: 'es' },
CommonService,
{
provide: NgbDateParserFormatter,
useFactory: () => new CustomNgbDateParserFormatter('longDate')
},
如果错误得到解决将
()=>{}
替换为function(){}
会有帮助。将()=>{}
替换为function(){}
会有帮助。在声明模块之前,请尝试这样导出函数
export function createCustomFormatter(): Function
{
return () => new CustomNgbDateParserFormatter('longDate');
}
然后在提供程序中使用该函数
providers: [
CommonService,
{
provide: NgbDateParserFormatter,
useFactory: createCustomFormatter
},
在声明模块之前,请尝试像这样导出函数
export function createCustomFormatter(): Function
{
return () => new CustomNgbDateParserFormatter('longDate');
}
然后在提供程序中使用该函数
providers: [
CommonService,
{
provide: NgbDateParserFormatter,
useFactory: createCustomFormatter
},
嘿,我有:useFactory:()=>新的CustomNgbDateParserFormatter('longDate')您是否建议将其转换为以下格式?useFactory:function(){return new CustomNgbDateParserFormatter('longDate');}请@user3875919,让我知道是的,让我们试试。对不起,我正忙于其他任务,现在它不需要了,但谢谢你的建议。嘿,我有:useFactory:()=>new CustomNgbDateParserFormatter('longDate')你建议将它转换为如下格式吗?useFactory:function(){return new CustomNgbDateParserFormatter('longDate');}请@user3875919,让我知道是的,让我们试试。对不起,我正忙于其他任务,现在不需要了,但谢谢你的建议。对不起,我正忙于其他任务,现在不需要了,但谢谢你的建议,现在不需要了,但是谢谢你的建议。