我正在使用Angular 6
和ngx-datatable
。
我有类似多维格式的数据
[
{
"remote": {
"app_name": "Test 1",
"app_url": "https://app.example1.io",
"created": "2018-10-31T09:01:32+00:00"
},
"users": [
{
"name": "Example 1",
"email": "example1@gmail.com",
"ip_address": null,
"created": "2018-10-30 19:26:57"
},
{
"name": "Example 2",
"email": "example2@ymail.com",
"ip_address": null,
"created": "2018-10-30 16:05:17"
}
]
},
{
"remote": {
"app_name": "Test 2",
"app_url": "https://app.example2.io",
"created": "2018-10-31T09:01:32+00:00"
},
"users": [
{
"name": "Example 3",
"email": "example3@gmail.com",
"ip_address": null,
"created": "2018-10-30 19:26:57"
},
{
"name": "Example 4",
"email": "example4@ymail.com",
"ip_address": null,
"created": "2018-10-30 16:05:17"
}
]
}
]
此处根数组元素具有两个键remote
和users
,其中users
也是一个数组。
我想以以下格式显示数据
如果子属性是单个属性,则可以使用(。)分隔符,例如
columns = [
{
prop: 'remote.app_name',
name: 'Application Name',
sortable: true
}
];
但是如何在数据表列中为用户名和电子邮件定义prop
?