1

我对如何在这些对象数组中获得 material.sku 的值感到困惑?这是我在下面尝试过的。在此处输入图像描述

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

1 回答 1

0

您应该访问第 0 个索引,

  <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>
于 2017-11-02T11:06:09.687 回答