javascript - Print array of objects -


i want print array of objects on template i'm getting problems trying it. json on theres 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, can see, historicois array of objects , want print texto values on screen. part of template try 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 use data 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 error:

cannot find differ supporting object '[object object]' of type 'object'. ngfor supports binding iterables such arrays.

can me? in advance

the error getting because of outer ngfor have:

<div *ngfor="let historico of disputa"> 

disputa object, , cannot therefore iterated.

just remove outer iteration , go, template should this:

<p *ngfor="let historico of disputa.historico"> {{historico.texto}} </p> 

here's

demo


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -