[英]How to use the Interface in another component? (getting error)
Why I am getting this error, I am setting my constructor in componentA like this,为什么我收到这个错误,我在 componentA 中设置我的构造函数,就像这样,
constructor(
private aaaa: AAAA
.
.
.
private customizePayload: CustomizePayload
){}
this CustomizePayload is in the model.ts class此 CustomizePayload 在 model.ts 类中
export interface CustomizePayload {
itemId: string;
itemVersion: number;
locale: string;
originalItemId: string;
originalItemVersion: number;
programId: string
programNames: string[];
targetMode: string;
}
When I run my app locally I am getting this error:当我在本地运行我的应用程序时,出现此错误:
vendor.js:2 Uncaught Error: Can't resolve all parameters for ContentRowComponent: ([object Object], [object Object], [object Object], [object Object], [object Object], ?).
Basically, I want to use the CustomizePayload interface and set its attribute values in componentA.基本上,我想使用 CustomizePayload 接口并在 componentA 中设置它的属性值。
That's not the correct way to add an interface to a component.这不是向组件添加接口的正确方法。 You're injecting it as if it were a dependency, which it's not.
您将其注入就好像它是一个依赖项,但事实并非如此。
Remove what you have from the constructor and import it into your component like this:从构造函数中删除您拥有的内容并将其导入到您的组件中,如下所示:
import { CustomizePayload } from 'app/_models/customize-payload.model';
Or wherever it is in your app.或者它在您的应用程序中的任何位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.