I'm creating a table with PrimeNG for an Angular app. It shall show the number of students by class. What I magaged to build is a table with one column for class names and one column to the number of students. What I need is one ROW for class names and one for the number of students. Is there a (clean code compatible) way to transpose a table?
Here is the table html:
<p-table [value]="getData()">
<ng-template pTemplate="header">
</ng-template>
<ng-template pTemplate="body" let-data>
<tr>
<td class="legend-cell" >
{{data.className}}
</td>
<td class="non-edit-cell" >
{{data.numStudents}}
</td>
</tr>
</ng-template>
</p-table>
This is my dummy data:
getData(){
let data = [];
data.push({className: 'Class 1', numStudents: 22})
data.push({className: 'Class 2', numStudents: 23})
data.push({className: 'Class 3', numStudents: 24})
return data;
}
The result table:
What I want (I bloodyly hardcoded this):

