【发布时间】:2021-04-30 12:06:13
【问题描述】:
我正在尝试在我的视图中显示“pat_nom”。
app.component.ts:
getPatient() {
this.prescriptionService.getPrescription().then((result: Patient[]) => {
if(!result){
return;
}
this.dataSource= new MatTableDataSource(result);
}
)
app.component.html:
<ng-container matColumnDef="pat_nom">
<th class="nom sortable" *matHeaderCellDef mat-sort-header>
<div>Nom Prénom</div>
</th>
<td class="nom" mat-cell *matCellDef="let element"> {{element.patients.pat_nom}} </td>
</ng-container>
患者.ts:
export interface Patient {
pat_nom: string;
pat_prenom: string;
pat_date_naissance:Date;
prescriptions: Array<string>;
ind_obs: number;
ind_iah: number;
ind_fuites: number;
}
我在 json 中的服务结果:
"patients": [
{
"ind_obs": "178",
"ind_iah": 2.75,
"pat_date-naissance": "1957-02-23 00:00:00.0",
"pat_prenom": "François",
"ind_fuite": 2.75,
"pat_id": "4405",
"prescriptions": [
{
"pres_type": "PPC"
},
{
"pres_type": "PPC"
}
],
"ind_niveau": 2,
"pat_nom": "ANDRE"
},
我正在尝试在我的视图中显示“pat_nom”。我认为我对此有问题
<td class="nom" mat-cell *matCellDef="let element"> {{element.patients.pat_nom}} </td>
我无法访问 pat_nom。
【问题讨论】:
-
您有拼写错误。它的
pat_prenom不是pat_nom -
不,我在 Patient 模型中有 pat_nom 和 pat_prenom。但我想显示 pat_nom
-
我在您的服务响应中看不到
pat_nom。 -
只是复制和粘贴的错误。我编辑我的代码知道
-
请在stackblitz分享代码
标签: angular angular-material datasource