I need to update a count within a nested loop and display the value (e.g. 1,2,3,4) when the table loads. The challenge is that my objects have varying lengths, so with 100 rows in the table, the counter column should display numbers from 1 to 100.
<ng-container *ngFor= "let lot of all;">
<tr *ngFor="let sensor of lot.income;" >
<td>{{count++}}</td> // incrementing counter
<td>{{lot.project.name}}</td>
<td>{{sensor.incomeNo}}</td>
</tr>
</ng-container>
My JSON object structure looks like this:
[
{
"project": {
"project": "project_one",
"code": "0000001"
},
"income": [
{
"incomeNo": 1,
"discount": 0
},
{
"incomeNo": 2,
"discount": 0
}
]
},
{
"project": {
"project": "project_two",
"code": "0000002"
},
"income": [
{
"incomeNo": 3,
"discount": 2
},
{
"incomeNo": 4,
"discount": 8
},
{
"incometNo": 5,
"discount": 14
},
{
"incomeNo": 6,
"discount": 3
}
]
}
]