0

TYPESCRIPT:

this.paises = this.api.getAllCountries();

        this.paises.forEach(item => {
            this.paisesData.push(item);
        });

ANGULAR:

 <ion-item button detail lines="inset" *ngFor="let pais of paisesData" (click)="paisesInfo(pais)">
            {{ pais.response }}
        </ion-item>

OBJECT OF ARRAYS:

How to list in its owns button every country that is inside response array?

QUESTION:

How to list in its owns button every country that is inside response array?

2 Answers 2

1

Just put another loop

<ion-item button detail lines="inset" *ngFor="let pais of paisesData" (click)="paisesInfo(pais)">
  <ul>
    <li *ngFor="let country of pais.response">{{ country }}</li>
  </ul>
</ion-item>
Sign up to request clarification or add additional context in comments.

1 Comment

That's it. Thank you.
0

Insert response data into the array and avoid multiple loops on template.

this.paises = this.api.getAllCountries();

    this.paises.forEach(item => {
        this.paisesData.push(item.response);
    });

HTML:

 <ion-item button detail lines="inset" *ngFor="let pais of paisesData" (click)="paisesInfo(pais)">
        {{ pais }}
    </ion-item>

1 Comment

I need the inner loop as sugested in previous answer because without it i'm not able to create separate buttons for every key.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.