0

I have some JSON data structured as:

[{"x":"Example1", "y":["1","2","3"],"id":"one"},{"x":"Example2", "y":["11","12","13"],"id":"two"}]

I am trying to bind the data so it shows:

One
1 2 3

Two
11 12 13

I'm pretty sure I'm doing this entirely wrong, but can't seem to get my head around it...! I can get a result using {{item.y[0]}}, but can't do this nested *ngFor.

  <ion-item *ngFor="let item of Data">
    <h2>{{item.id}}</h2>
    <h3 *ngFor="let y of item">{{item.y}}</h3>
  </ion-item>

Thank you in advance for any help.

2 Answers 2

2

I think what you are trying to do is the following:

<h3 *ngFor="let y of item.y">{{y}}</h3>
Sign up to request clarification or add additional context in comments.

1 Comment

Perfect. Thanks so much Alex
0
<ion-item *ngFor="let item of Data">
    <h2>{{item.id}}</h2>
    <h3 *ngFor="let y of item.y">{{y}}</h3>
</ion-item>

1 Comment

While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.