Array in Ionic of json file

Asked

Viewed 965 times

0

I have the following JSON document

"descritores": [{
        "descritor": "texto..",
        "resultado": [{
                "MediaTotal": "81,16"
            },

            {
                "MediaTotal": "81,16"
            }
        ]
    },
    {
        "descritor": "Texto 2..",
        "resultado": [{
                "MediaTotal": "87,01",
            },
            {
                "MediaTotal": "87,01",
            }
        ],
    },

And I’m showing off like this on Ionic

 <ion-list>
         <ion-item *ngFor="let desc of descritores">
      <h2>{{desc.descritor}}</h2>
      <h3>Resultado{{desc.resultado.MediaTotal}}</h3>
      <p>Disponível</p>
</ion-item>

But I’m having trouble showing off desc.resultado.MediaTotal, which is an array that is inside another array, as I do to display.

1 answer

1


You can display the result inside another for:

<ion-list>
    <ion-item *ngFor="let desc of descritores">
        <h2>{{desc.descritor}}</h2>
        <ion-item *ngFor="let media of desc.resultado">
            <h3>Resultado: {{media.MediaTotal}}</h3>            
        </ion-item> 
        <p>Disponível</p>
   </ion-item>
</ion-list>
  • Actually the value of Mediatotal will be different for each one, the ones I put there were just as an example. So Mediatotal can appear 1 or N times. How do I display all of them?

  • I updated the reply @Leyssonguimarães

  • Thanks for the help. I was breaking my head to finish a module of my app. vlw msm guys

Browser other questions tagged

You are not signed in. Login or sign up in order to post.