How do I create a table with dynamic columns and rows in angular2
I have the data coming from a rest service and captured in this observable
this._physicalDataService.getPhysicalData().subscribe(res=> this.data = res)
I can display the rows dynamically through this code. How do I make the columns and the column headers dynamic too ie how can i extract all the JSON keys in an array to put another loop on top.
To clarify my backend service may return different datasets with different columns and row and I want to show them dynamically on a page.
<thead class="no-bd">
<tr>
<th>Id</th>
<th>Number</th>
<th >Employee Name</th>
<th >Manager Name</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let tablerows of data">
<td>
{{tablerows.row_id}}
</td>
<td>{{tablerows.number}}</td>
<td >{{tablerows.employee_name}}</td>
<td >{{tablerows.manager_name}}
</td>
</tr>