I have a table component which takes an input JSON for the table format and another JSON for the data. My question is, when my table is rendered with *ngFor, how do I call cellFunction?
My table format JSON:
tblFormat= [
{ headerTxt: 'Order ID', df: 'Order_ID', color: 'blue', cellFunction: 'testME1' },
{ headerTxt: 'Buyer Name', df: 'name', color: 'blue',cellFunction: 'testME2' }
]
My Component
import { Component, AfterViewInit, ViewChild, Input } from '@angular/core';
@Component({
selector: 'table-comp',
template: `<table class="table table-hover">
<thead>
<tr>
<th *ngFor="let h of tableInfo" [style.color]="h.color">{{h.headerTxt}}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let d of data">
<td *ngFor="let c of tableInfo" [style.color]=" how do I? c.cellFunction()">
{{d[c.df]}}
</td>
</tr>
</tbody>
</table>`
inputs: ['data','tableInfo']
})
export class TableComp {
tableInfo=[];
data=[];
}