* ngFor内部* ngFor

I have an array that holds a user's orders, and inside of it there is another array that holds his ordered items: enter image description here

我的问题是:如何遍历他的订单[]-> orderItems []

现在,我手动进行此操作只是为了确保它能正常工作

HTML档案:

 <tbody class="text-center">
                <tr *ngFor = "let order of myOrders;">
                    <td>{{order.orderItems[0].product_Name}}</td>
                    <td>{{order.orderItems[0].product_Price | currency: '$'}}</td>
                    <td>{{order.orderItems[0].product_Quantity}}</td>
                    <td colspan="6">{{order.orderItems[0].product_Price* order.orderItems[0].product_Quantity | currency: '$'}}</td>
                </tr>
                
            </tbody>

TS文件:

export class ProfileOrdersComponent implements OnInit {

  myOrders: OrderDetails[];
  constructor(private userService : UserService) { }

  ngOnInit() {
    this.userService.getProfileOrders().subscribe((data:OrderDetails[]) =>{
      this.myOrders = data
      console.log("My Orders:", this.myOrders);
    })
  }

}

感激!

评论