簡體   English   中英

如何在另一個組件中使用接口? (得到錯誤)

[英]How to use the Interface in another component? (getting error)

為什么我收到這個錯誤,我在 componentA 中設置我的構造函數,就像這樣,

constructor(
     private aaaa: AAAA
     .
     .
     .
     private customizePayload: CustomizePayload
 ){}

此 CustomizePayload 在 model.ts 類中

export interface CustomizePayload {
    itemId: string;
    itemVersion: number;
    locale: string;
    originalItemId: string;
    originalItemVersion: number;
    programId: string
    programNames: string[];
    targetMode: string;
    } 

當我在本地運行我的應用程序時,出現此錯誤:

vendor.js:2 Uncaught Error: Can't resolve all parameters for ContentRowComponent: ([object Object], [object Object], [object Object], [object Object], [object Object], ?).

基本上,我想使用 CustomizePayload 接口並在 componentA 中設置它的屬性值。

這不是向組件添加接口的正確方法。 您將其注入就好像它是一個依賴項,但事實並非如此。

從構造函數中刪除您擁有的內容並將其導入到您的組件中,如下所示:

import { CustomizePayload } from 'app/_models/customize-payload.model';

或者它在您的應用程序中的任何位置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM