Having trouble displaying the JSON values of certain properties on screen.
Utilizing Angular Material table to showcase my JSON response.
The code snippet below is responsible for rendering the JSON data:
<mat-card-content class="dashboard-card-content">
<div></div>
<div *ngIf="card.title===title1" class="custom-table-container mat-elevation-z8">
<table mat-table [dataSource]="dataSourceGeneralShift" class="">
<!-- Name Column -->
<ng-container matColumnDef="Name">
<th mat-header-cell *matHeaderCellDef> Name </th>
<td mat-cell *matCellDef="let col" class="align-left"> {{col.Name}} </td>
</ng-container>
<!-- day10 Column -->
<ng-container matColumnDef="day10">
<th class="table-header" mat-header-cell *matHeaderCellDef> Shift </th>
<td mat-cell *matCellDef="let col" class="align-left" > {{col | json}} </td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"> </tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns;"> </tr>
</table>
</div>
</mat-card-content>
In the day10 column, I'm using {{col | json}}
to verify API data retrieval!
Need to display Month values from day1 to day31.
The returned JSON value assigns day1 on the 1st of every month, day2 on the 2nd of every month and so forth. Each 'day-' property holds distinct values like 'Shift 1', 'Shift 2' etc.
Every JSON response varies. For instance:
day15 response
[
{
"Name": "Bravo",
"day15": "Shift 1"
}
]
day20 response
[
{
"Name": "Adam",
"day20": "Shift 2"
}
]
** Problem:** How to handle the changing key values (day1 to day31) while rendering them in the Angular Material table template?