我有以下primeng数据表配置:
face->glyph
和html:
private cars : any =
{
"data": [
{ "time": "9:30AM-10:30AM",
"Monday": {"Subject": "Physics"},
"Tuesday": 2012,
"Wednesday": "Orange",
"Thursday": "dsad231ff",
"Friday": "dsad231ff"
},
{ "time": "10:30AM-11:00AM",
"Monday": {"Subject": "Maths"},
"Tuesday": 213213,
"Wednesday": "efrwr",
"Thursday": "dsad231ff",
"Friday": "aaaaa"
},
]
}
cols: any = [
{field: 'time', header: ''},
{field: 'Monday', header: 'Monday'},
{field: 'Tuesday', header: 'Tuesday'},
{field: 'Wednesday', header: 'Wednesday'},
{field: 'Thursday', header: 'Thursday'},
{field: 'Friday', header: 'Friday'}
];
正如您在数据中看到的,其中一个值是对象<p-dataTable [value]="cars">
<p-column *ngFor="let col of cols" [field]="col.field" [header]="col.header"></p-column>
</p-dataTable>
在表格单元格中,如何使用键"Monday": {"Subject": "Physics"},
显示对象的值?目前我在我的手机中看到一个对象。在此先感谢你们
答案 0 :(得分:1)
@blackdaemon,
更新您的cols配置,如下所示: {field:'Monday.Subject',标题:'星期一'}
PrimeNg将字段称为对象。
请尝试更新。