【发布时间】:2021-08-18 09:25:11
【问题描述】:
我正在尝试使用下面的 json 结构创建下表。
{"status":200,"message":"success","result":{"report":[["SOUTH","ANDHRA-PRADESH","ITR",0.0000,0.0000,null,229.9800,0.0000],
["SOUTH","ANDHRA-PRADESH","OPC",84490.0000,6426.2000,0.0000,7183.7800,77306.0000]
]}}
到目前为止我尝试过的示例代码。非常感谢您的帮助...在此先感谢 https://stackblitz.com/edit/angular-mp1jro?file=src%2Fapp%2Fapp.component.ts
<table style="border:1px solid #CCC">
<thead>
<tr>
<th rowspan="2">Zn</th>
<th rowspan="2">P Name</th>
<ng-container *ngFor="let unique of arr">
<th rowspan="1" colspan="4">{{unique.grade}}</th>
</ng-container>
</tr>
<tr>
<th>I</th>
<th>II</th>
<th>III</th>
<th>IV</th>
<th>V</th>
<th>VII</th>
<th>VIII</th>
<th>8</th>
<th>9</th>
<th>10</th>
<th>11</th>
<th>12</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let hero of result.report;let i = index">
<td>{{hero[0]}}</td>
<td>{{hero[1]}}</td>
<td>{{hero[3]}}</td>
<td>{{hero[4]}}</td>
<td>{{hero[5]}}</td>
<td>{{hero[6]}}</td>
</tr>
</tbody>
</table>
【问题讨论】:
-
你的代码有什么问题?
-
我需要根据不工作的条件显示 IRT 和 OPC 列?...基于 IRT 或 OPC,它必须将数据显示到相应的列中。它仅在 IRT 中显示。
-
哪种情况?你有
ngIf那些 -
@MaliNaeemi 请检查附加的 stackblitz...