I am trying to generate a table based on a JSON configuration. Although I can create the table headers OK, I don't know how to dynamically select the row cell data by field name. This is what I have:
columns = [
{
heading: "Person's Name",
fieldName = "name"
},
{
heading: "Person's Age"
fieldName = "age"
} ];
people = [
{
name: "john",
age: 25,
gender: "male"
},
{
name: "mary",
age: 18,
gender: "female"
} ];
<table>
<tr>
<th *ngFor="let column of columns">{{column.heading}}</th>
</tr>
<tr *ngFor="let person of people">
<td *ngFor="let column of columns">{{person.column.fieldName}}</td>
</tr>
</table>
Clearly {{person.column.fieldName}} does not work i.e. this does not translate into person.name and person.age.
Any thoughts on how to select the person field with the name of the fieldName specified in columns data?