So I have this JSON objects
[
{
"defectClassification": "Wrong Color",
"sample": 0,
"defect": "CRITICAL"
},
{
"defectClassification": "Delamination",
"sample": 0,
"defect": "CRITICAL"
},
{
"defectClassification": "Major Dents",
"sample": 0,
"defect": "MAJOR"
},
{
"defectClassification": "Minor Misalignment",
"sample": 0,
"defect": "MINOR"
},
{
"defectClassification": "test critical",
"sample": 0,
"defect": "CRITICAL"
},
{
"defectClassification": "test major",
"sample": 0,
"defect": "MAJOR"
},
{
"defectClassification": "test minor2",
"sample": 0,
"defect": "MINOR"
},
{
"defectClassification": "Wrong Color",
"sample": 1,
"defect": "CRITICAL"
},
{
"defectClassification": "Slight Color Variation",
"sample": 1,
"defect": "MINOR"
},
{
"defectClassification": "Placement Misalignment",
"sample": 10,
"defect": "MAJOR"
},
{
"defectClassification": "Major Blisters",
"sample": 10,
"defect": "MAJOR"
},
{
"defectClassification": "test minor2",
"sample": 10,
"defect": "MINOR"
}
]
This is my component:
<mat-tab-group
[selectedIndex]="selected.value"
(selectedIndexChange)="selected.setValue($event)"
>
<!-- <li class="nav-item"> -->
<mat-tab *ngFor="let tab of tabs; let tabIndex = index" [label]="tab">
<div class="tab-content card-body">
<div class="row">
<div class="col-sm-4">
<div class="table-responsive">
<table class="table table-bordered table-hover" id="criticalTable">
<thead class="thead-light">
<tr>
<th>
Defect Classification
<span class="text-danger">(Critical)</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>test</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-sm-4">
<div class="table-responsive">
<table class="table table-bordered table-hover" id="majorTable">
<thead class="thead-light">
<tr>
<th>
Defect Classification
<span class="text-warning">(Major)</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>tests</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-sm-4">
<div class="table-responsive">
<table class="table table-bordered table-hover" id="minorTable">
<thead class="thead-light">
<tr>
<th>
Defect Classification
<span class="text-success">(Minor)</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>test3</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</mat-tab>
<!-- </li> -->
</mat-tab-group>
Now what I want is that I want to display this data in each sample(tab). So sample #0 should display all data with sample 0. Each sample has 3 tables (critical, major, and minor). So each sample has different data based on the given json objects. How to achieve this?
You can use this stackblitz link.