How to loop with *ngFor in array of objects?

Discussão em 'Angular' iniciado por tholo, Setembro 11, 2024.

  1. tholo

    tholo Guest

    I'm learning Angular2, so please forgive me if I'm asking a stupid question. I am receiving an arrays of objects and it looks like this:

    obj.json

    data: [
    {
    item: "banana"
    }
    ],
    [
    {
    item: "apple"
    }
    ],
    [
    {
    item: "lemon"
    }
    ]


    In my component file I have managed to scope it in a scope:

    this.fruits = data[0].item;


    The issue is I only manage to scope the first item, or the second item and so on, by the index. How can I scope them all and then show them in a HTML file with *ngFor?

    Continue reading...

Compartilhe esta Página