As I attempt to extract data from a json file and create an HTML table, certain sections of the code are functioning correctly while others are displaying index errors. All relevant files are provided below. This issue pertains to Angular. This is my json file
{
"Users": [
{
"id": 1,
"firstName": "Nitin",
"lastName": "Rana",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bad4d3ced3d494c8dbd4dbfaddd7dbd3d694d9d5d7">[email protected]</a>",
"mobile": "2345678901",
"salary": "25000"
},
{
"id": 2,
"firstName": "Rajat",
"lastName": "Singh",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1163707b70653f62787f76792051767c70787d3f727e7c">[email protected]</a>",
"mobile": "5637189302",
"salary": "30000"
},
...
]
}
and this is my HTML file
<h1>Table using JSON Server API</h1>
<hr>
<table id="users">
<tr>
<th *ngFor="let col of columns">
{{col}}
</th>
</tr>
<tr *ngFor="let user of users">
<td *ngFor="let col of index">
{{user[col]}}
</td>
</tr>
</table>
In my output
<th *ngFor="let col of columns">
{{col}}
</th>
this part of code is executing fine, but the following section is encountering an error indicating that
No index signature with a parameter of type 'string' was found on type 'Users'.
<tr *ngFor="let user of users">
<td *ngFor="let col of index">
{{user[col]}}
</td>
I would greatly appreciate any assistance in resolving this index error that has been perplexing me.