I have an input JSON string from server. It can have any number of columns. I want to be able to create MAT angular table from this JSON. This is my test environment https://stackblitz.com/edit/angular-wcjorj
Currently, I'm hard coding all column names in the html page. For each column I use ng-container like this:
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef mat-sort-header> ID </th>
<td mat-cell *matCellDef="let row"> {{row.id}} </td>
</ng-container>
But I need to be able to do this dynamically, for any other JSON data table. How can I create that html table dynamically? I tried to use ngFor, however, it got very messy and I wasn't able to make it work