2
I have the following array called dadosRelatorio
that I need to iterate in my template, that array I get through a request from my backend.
[{"id": 1,
"name": "a",
"class":[{
"Inglês":[{
"id": 1,
"code": "teste"
},
{
"id": 2,
"code": "teste 2"
}],
"Espanhol":[{
"id": 1,
"code": "a"
}]
}]
}]
How can I iterate objects within class if they have different names? Occasionally it can come "Inglês"
, occasionally "Espanhol"
, among other languages.
Usually I do the *ngFor
passing the name of the object, but in this case I do not know the name of the object because it varies:
<div *ngFor="let aluno of dadosRelatorio" class="div-aluno">
<span>Aluno: {{ aluno.name }}</span>
<div *ngFor="let classe of aluno.class">
<div *ngFor="let idioma of classe. ???>
</div>
</div>
</div>
ai Voce has to map its array for their keys to be a property
– Eduardo Vargas