我有一个遗留代码,到目前为止我还没有完全理解,但必须进行维护,哈哈)
代码是由我在下面描述的组件编写的,它可以与
ng serve
,但与
ng build --prod
.
问题在于
providers
字段:
@Component({
selector: "legacy-component",
templateUrl: './legacy-component.component.html',
styleUrls: ['./legacy-component.scss'],
//Take a look at "providers", the problem is there
providers: [provideWidget(LegacyComponent, {
id: "legacy",
options: {},
layout: { minCols: 2, cols: 4, rows: 2 },
info: {
name: "Legacy Compoent",
image: "assets/img/legacy/legacy.png",
description: ""
}
})]
})
export class LegacyComponent {...}
我真的不明白提供商的情况,但当我尝试构建项目时,我有:
Error during template compile of 'LegacyComponent'
Function expressions are not supported in decorators in 'provideWidget'
'provideWidget' contains the error at some/path/other-class.ts
Consider changing the function expression into an exported function.
但如果我重写
provideWidget
作为函数,我会有不同的错误:
Error during template compile of 'LegacyComponent'
Function calls are not supported in decorators but 'provideWidget' was called.
我猜
在提供者中进行函数调用可能不是一个好主意,但我应该启动代码并
我就是无法取代
唯利是图
由于函数的复杂逻辑,使用一些静态数据调用。
有人知道在这种情况下如何构建生产版本吗?