0
I get following Json:
I would like to show on screen the following fields in a table:
standings>0>table>All returns from 0 to n
What I have so far is:
<div *ngFor="let tabelas of campeonato.standings | keyvalue">
<div >
<table class="table table-striped">
<thead class="thead-dark">
<tr>
<th>#</th>
</tr>
</thead>
<tbody ng-if="tabelas.value.type == TOTAL ">
<tr>
<td>{{tabelas.value.type}}</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="7" class="text-center">
<h4>Nenhum Campeonato Encontrado.</h4>
</td>
</tr>
</tfoot>
</table>
</div>
But I’m not getting to the fields of table
The problem is in
ngFor
, try like this:*ngFor="let tabelas of campeonato.standings[0].table | keyvalue"
– OtavioCapel
I got the following mistake
ERROR TypeError: Cannot read property '0' of undefined
– Matheus
because you’re using the keyvalue pipe?
– Eduardo Vargas
I was trying to use the key to be able to do an if by
standings[0]
– Matheus
Try *ngFor="Let tables of championship.standings[0]. table" without the keyvalue. And puts a championship ngIf in a div above that ngFOr to make sure the backend response has arrived.
– Eduardo Vargas
@Eduardovargas remains the same problem,
ERROR TypeError: Cannot read property '0' of undefined
, he is doing the foreach correctly, but this error continues– Matheus
it is pq it is Undefined until the answer of the back, to solve or vc start it empty somehow or make a ngif around it
– Eduardo Vargas