I want to print an array of objects on my template but I'm getting some problems trying to do it. This is the json on which theres the array historico
{
"id": 2,
"tipo_negociacao": "Cobrança",
"historico": [
{
"fl_usuario": "",
"created_at": "",
"updated_at": "",
"created_by": null,
"updated_by": null,
"texto": "Proposta realizada valor de R$666666666"
},
{
"texto": "Proposta no valor de R$:5762recusada"
},
{
"texto": "Proposta realizada valor de R$6750"
},
}
So, as you can see, historicois an array of objects and what I want to do is to print all texto values on the screen.
This is the part of the template where I try to print it:
<div *ngFor="let historico of disputa">
<p> Negociação não iniciada </p>
<p *ngFor="let historico of disputa.historico"> {{historico.texto}} </p>
</div>
Im using this to use data from disputa:
this.route.params.subscribe(params =>{
let id = params['id'];
this.service
.buscaPorId(id)
.subscribe(disputa => {
this.disputa = disputa;
},
erro => console.log(erro));
})
Im getting this error:
Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
Can someone help me? Thanks in advance
let historico of disputasshould bedisputathat's the name of the array. Update: and be careful about the naming of your variables, the first variable in which you save disputas it's fine but I think the second one will cause conflictbuscaPorId(id)call is not an array. If you do aconsole.log(this.disputa));after the service call, does show an array, or an object?