I want to increment a counter value inside a nested for loop and print the value(like 1,2,3,4) when the table is loaded. But the problem is I have values with different length in my objects. think there are 100 rows in the table so the counter column must print 1-100.
<ng-container *ngFor= "let lot of all;">
<tr *ngFor="let sensor of lot.income;" >
<td>{{count++}}</td> // counter here
<td>{{lot.project.name}}</td>
<td>{{sensor.incomeNo}}</td>
</tr>
</ng-container>
My object is look like this in JSON.
[
{
"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
}
]
}
]