Sandeep Nambiar
Sandeep Nambiar

Reputation: 1676

Bind values inside a multiple for loop in angular 6

I have two loops in my template file.i am trying to bind second value using first loop value.But i am getting error.

<tr *ngFor="let splitdata of mf.data">
  <td *ngFor="let slitup of searchFieldsslitup">
    {{splitdata.slitup.headName}}
  </td>
</tr>

Upvotes: 0

Views: 204

Answers (2)

Muhammad Abdullah
Muhammad Abdullah

Reputation: 482

you could also try this:

<tr *ngFor="let splitdata of mf.data">
  <td *ngFor="let slitup of splitdata">
    {{slitup.headName }}
  </td>
</tr>

Upvotes: 0

Martin Parenteau
Martin Parenteau

Reputation: 73751

Use the bracket notation to access the properties by their name:

<tr *ngFor="let splitdata of mf.data">
  <td *ngFor="let slitup of searchFieldsslitup">
    {{ splitdata[slitup.headName] }}
  </td>
</tr>

Upvotes: 1

Related Questions