'Keys' (keys: any;) represent the headers extracted from 'data.items[0]' using the 'object.keys' method.
How can I properly loop through the objects in 'data.items'? Using *ngFor does not seem to work as expected.
Here is the desired outcome: https://i.sstatic.net/aqtlc.png
However, I encounter an error when trying to access 'item.header',
The property 'header' does not exist on the type '{ name: string; alias: string[]; qty: number; price: number; total: number; }'
If I use 'item[header]'
Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{ name: string; alias: string[]; qty: number; price: number; total: number; }
CODE
Object
private itemData: sale = {
type: '',
data: { date: ' ', InvoiceNo: ' ', tax: ' ' },
total: { semitotal: 0, grandtotal: 0 },
items: [
{ name: 'item 1', alias: ['01a'], qty: 0, price: 0, total: 0 },
{ name: 'item 2', alias: ['02a'], qty: 5, price: 250, total: 0 },
{ name: 'item 3', alias: ['03a'], qty: 6, price: 350, total: 0 },
{ name: 'item 4', alias: ['04a'], qty: 1, price: 150, total: 0 },
],
params: {},
};
Angular HTML Code
<tbody>
<tr *ngFor="let item of itemData.items" class="table-data" >
<td *ngFor="let header of headers">
<input type="text" [value]="item.header"> <---------- Issue
</td>
</tr>
</tbody>