在Angular中读取Array内部的数组

时间:2017-11-02 11:04:35

标签: arrays angular object ngfor angular-ng

我很困惑如何在这些对象数组中获得material.sku的值?这就是我在下面尝试的内容。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);
 })

1 个答案:

答案 0 :(得分: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>