如何将嵌套数组显示为 Angular Material Table 中的行?

How to display nested arrays as rows in Angular Material Table?

我正在尝试在 [=25] mat-table 中显示 错误日志 (applicationErrors 数组)中的 table =] 看起来像这样: Respone JSON

我想这样显示我的table:

Production name | Application name | Request Time | Log

Fifth Production | Fifth Application | 2020... | log error

Fifth Production | Fifth Application | 2020... | next log error

我应该如何遍历它以获得上述结果有什么想法吗?

在“正常”中 table 这很容易做到,但我不知道如何在 mat-table 中做到这一点(我想通过列使用分页和过滤)。

您可以简单地通过使用 for 循环并遍历数组来完成此操作。

您只需维护一个数组,用于显示 table 中的数据。

请使用以下代码来实现您的要求。

Let dataArray:any[]=[];
this.data.forEach((production)=>{
  production.application.forEach((application)=>{
     application.applicationErrors.forEach((error)=>{
      let obj = {'product':production.name,'application':application.name,'request time':error.requestTime,'log':error.log}
     dataArray.push(obj)
  })
}) 

})