[英]How to display Table of following data Table in HTML of Angular 7 Application obtained through through .TS call from API
[英]Display relationship api data in html table - Angular
基本上我在educational_awards
中有一個關系數據並且有一個領域award
我試圖將該數據顯示到我的 html 表中,但它不會顯示。
<tr *ngFor="let item of data; let i = index">
<td>
{{ item.year }}
</td>
<td>
{{ item.course }}
</td>
<td>
{{ item.educational_awards.award }}
</td>
</tr>
我嘗試的是在我的 model 中添加獎勵類型,但它顯示“未定義的獎勵”
export interface IUserEducationalBackground {
id: number;
user_id: number;
studies_type: string;
year: number;
course: string;
educational_awards?: EducationalAward ;
}
interface EducationalAward {
id?: number;
award?: string;
}
我這樣做是對的還是完全錯誤的。 angular 相當新,所以我很困惑。
item.educationalAward.award
需要改為item.educational_award[0].award
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.