【发布时间】:2020-03-01 03:49:36
【问题描述】:
我已将包含对象数组的对象数组传递给 mat 表中的 dataSource。 我无法遍历具有对象数组的对象。
const roleListData = [
{
roleId: 1,
role: "admin",
description: "Testing",
level: "1",
roleFunctions: [
{
createdBy: "person-1",
createdOn: "2019-11-04T20:02:52.345",
updatedBy: null,
updatedOn: null,
segmentId: 2,
segmentType: "Dealer",
segmentName: "testing",
segmentValue: "5",
additionalInfo: null,
active: true
}
]
}
]
roleFunctions 的表格单元格:
<ng-container matColumnDef="roleFunctions">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Functions</th>
<td mat-cell *matCellDef="let row">
{{ item }}
</td>
</ng-container>
我需要访问具有对象数组的角色函数对象。如果该数组没有任何对象,那么它也应该可以正常工作而没有任何问题。因为根据我的要求,对象可能包含也可能不包含对象数组。如果它们存在,那么我应该能够在该表 cel 中显示内部对象信息。
【问题讨论】: