How to walk a json with ionic 3

0

I'm working with ionic3 and angular4, I'm running a json from a rest api (through the url) without any problem, but I just want to access a specific data of this json. For example, only to position "1".

Home.ts:

To tour it:

 <ion-item *ngFor="let post of posts; ">

  <h1>{{post.enunciado_pregunta}}</h1>
  <br>

</ion-item>
    
asked by flo 15.05.2018 в 23:49
source

2 answers

0

Well if you have control of the api you should do something like this: link so you will only recover only what you need you should not consult all the records, or I do not understand your question well, you could clarify it

    
answered by 16.05.2018 в 00:09
0

What kind of partner?

In order to solve your problem, you have to make a console.log to your response and see if you already have the data in said variable .

Once you have noticed that everything is going correctly, you have to place the values in a array and the variable posts is not initialized as a array . So what you have to do is place it in the following way:

  

posts: any [] = [];

This way you can already make a for to your list. Also tell you that it would be better to use <ion-list></ion-list> to iterate your ion-item

I hope I will help you and tell me if you solved it.

Greetings.

    
answered by 24.05.2018 в 03:07