代码之家  ›  专栏  ›  技术社区  ›  Kael

在html表格中显示关系api数据-角度

  •  0
  • Kael  · 技术社区  · 1 年前

    基本上我有一个关系数据 educational_awards 并且有一个字段 award enter image description here

    我试图将这些数据显示到我的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>
    

    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来说相当陌生,所以我很困惑。

    1 回复  |  直到 1 年前
        1
  •  0
  •   paranaaan    1 年前

    item.educationalAward.award 需要更改为 item.educational_award[0].award

    推荐文章