0

I need to populate table with two different arrays "A" and "B" into a same row.

let A = ["a","b","c","d"]
let B = ["success","success","success","success"];

HTML

<tbody>
  <ng-container *ngFor="let alphabet of A; let i = index">
  <tr *ngFor="let status of B; let i = index">
  <td >{{ alphabet }}</td>
  <td >{{ status }}</td>
  </tr>
  </ng-container>
</tbody>

But here with this i get repeated set of rows

Expected:

a    success
b    success
c    success
d    success
1
  • Not found any issue with your code Commented Jul 28, 2020 at 10:21

1 Answer 1

2

You can access the the data of the second array by its index:

<tbody>
  <tr *ngFor="let alphabet of A; let i = index">
  <td >{{ alphabet }}</td>
  <td >{{ B[i] }}</td>
  </tr>
</tbody>
Sign up to request clarification or add additional context in comments.

Comments

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.