user8743396
user8743396

Reputation:

Read Array inside of Array in Angular

I'm confused on how would i get the value of material.sku in these arrays of objects? This is what i have tried below.enter image description here

html

<td>
    <select formControlName="material_id" class="col-md-12">
        <option *ngFor="let mat_order of mat_orders.materials" [ngValue]="mat_order.material_id">
            {{ mat_order.sku}} 
        </option>
    </select>
 </td>

ts

.subscribe(
  (data:any) => {
    this.mat_orders = data.supplies;
    console.log(mat_orders);

  },
  error => {
   alert("Error");
   console.log(error);
 })

Upvotes: 1

Views: 3996

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222532

you should access the 0th index,

  <select formControlName="material_id" class="col-md-12">
        <option *ngFor="let mat_order of mat_orders[0].materials" [ngValue]="mat_order.material_id">
            {{ mat_order.sku}} 
        </option>
    </select>

Upvotes: 1

Related Questions