How to iterate array inside an angular / ionic ngFor

0

I have the following template:

export interface Perguntas{
     historico:[{id_historico: number, resposta_historico: string}]
}

In my ts file I perform an http request for a service that returns this data to me, if I give a console.log (this.questions), I get my data as follows:

I need to iterate through this data in my template, I tried something like:

<ion-card *ngFor="let pergunta of perguntas; let i = index">

<p>{{pergunta.data}}</p>

Here it works correctly, my problem is in iterating the historical array, I tried:

<div class="message">{{pergunta.historico.pergunta_historico}}</div>

Why does not it work? No error message is displayed on my console, however the value is not shown.

    
asked by anonymous 02.08.2018 / 19:28

1 answer

0

The .historical question is also an array. You have to iterate this array. Something like:

<div class="message" *ngFor="let historico of pergunta.historico> 
    {{historico.pergunta_historico}}
</div>
    
02.08.2018 / 19:47