简体   繁体   中英

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. 在此处输入图片说明

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);
 })

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM