Nested curly braces/data bindings

Discussão em 'Angular' iniciado por Faigjaz, Dezembro 5, 2024.

  1. Faigjaz

    Faigjaz Guest

    I am using Angular2 for my app. In my html I have a *ngFor like this:

    <div *ngFor="let element of array">
    {{element.id}}
    </div>


    Then I have an array of objects like this:

    someData: [{element.id: 511}, {element.id : 123}]
    //Just some data in the values, nothing special


    What I need is now to nest those two data-bindings and I actually couldn't find any good advice.

    What I want is something like this:

    <div *ngFor="let element of array">
    {{element.id}}
    <p>{{someData[{{element.id}}]}} </p>
    </div>


    So my question is whether this is even possible and how. Or, if you have any advice to achieve the same thing in a different way, I'd love to hear that, too. The only thing is, that I can't change any of my arrays, as I need the "element.id" property in "someData" to know which values go with another. Thanks so far!

    Continue reading...

Compartilhe esta Página