Arrays 试图显示一个对象

Arrays 试图显示一个对象,arrays,json,angular,object,Arrays,Json,Angular,Object,我正在做一个按月分组交易的项目,但遇到了一些麻烦。出于某种原因,我的表只输出以下内容:“[object]”如果有人能指出我遗漏了什么,我将不胜感激!:D 这是一个ts文件,它将阵列按月份分组,然后显示这些月份: export class TableJsonComponent implements OnInit { transactions: any = []; constructor(private httpClient: HttpClient) {} ngOnInit() {

我正在做一个按月分组交易的项目,但遇到了一些麻烦。出于某种原因,我的表只输出以下内容:“[object]”如果有人能指出我遗漏了什么,我将不胜感激!:D

这是一个ts文件,它将阵列按月份分组,然后显示这些月份:

export class TableJsonComponent implements OnInit {
  transactions: any = [];

  constructor(private httpClient: HttpClient) {}

  ngOnInit() {
    this.httpClient.get("assets/transactions.json").subscribe(data => {
      console.log(data);
      this.transactions = data;
    });
    this.getData();
  }

  getData() {
    const monthName = item =>
      moment(item.transaction_date, "YYYY-MM-DD").format("MMMM");
    this.httpClient.get("assets/transactions.json").subscribe(data => {
      console.log(data);
      this.transactions = _.chain(this.transactions)
        .groupBy(monthName)
        .mapValues(items => _.map(items, "customer.name"))
        .value();_.map(Object, 'data');
    });

    const byMonth = _.chain(this.transactions)
      .groupBy(monthName)
      .mapValues(items => _.map(items, "customer.name"))
      .value();_.map(Object, 'data');
    console.log(byMonth);
    return byMonth;
    console.log(this.transactions);
  }
}
此表显示了阵列中的所有数据:

<table class="table" *ngFor="let month of transactions | keyvalue">
    <tr>
        <th>{{month.key}}</th>
    </tr>
    <tr>
        <td>
            <table class="table" *ngFor="let customer of month.value">
                <tr>
                    <td>{{customer}}</td>
                </tr>
            </table>
        </td>
    </tr>
</table>
试试这个:

<table class="table"  *ngFor="let month of transactions | keyvalue">
    <tr >
        <th>{{month.key}}</th>
    </tr>
    <tr  >
        <td  >
            <table class="table" *ngFor="let d of month.value">
                <tr>
                  <td><strong>id:</strong> {{d.id}}</td>
                    <td><strong>billing_stage_net_value:</strong> {{d.billing_stage_net_value}}</td>
                     <td><strong>customer: </strong>{{d.customer.name}}</td>
                </tr>
            </table>
        </td>
    </tr>
</table>

{{month.key}
id:{{d.id}
计费阶段净值:{{d.计费阶段净值}
客户:{{d.customer.name}
像这样试试

 <table class="table" id="customers">
    <thead>
        <tr>
            <th *ngFor="let customer of transactions[0] | keyvalue ">{{customer.key}}</th>
        </tr>
    </thead>
    <tbody>
        <tr *ngFor="let customer of transactions">
            <td>{{customer.billing_stage_net_value | date}}</td>
            <td>{{customer.customer.name}}</td>
            <td>{{customer.id}}</td>
            <td>{{customer.transaction_date | date}}</td>
        </tr>
    </tbody>
</table>

{{customer.key}
{{customer.billing_stage_net_value|date}
{{customer.customer.name}
{{customer.id}
{{customer.transaction_date|date}

它只列出了日期,但没有像我在演示中那样保留月份分组。好的,看起来不错,但它仍然没有像我从硬编码数组中提取数据时那样显示月份名称。这里是重新制作的问题:试试这个:我想在页眉中有月份,每个月的客户嵌套在第n行。这样做会每次增加月份,而不是将它们组合在一起。
 <table class="table" id="customers">
    <thead>
        <tr>
            <th *ngFor="let customer of transactions[0] | keyvalue ">{{customer.key}}</th>
        </tr>
    </thead>
    <tbody>
        <tr *ngFor="let customer of transactions">
            <td>{{customer.billing_stage_net_value | date}}</td>
            <td>{{customer.customer.name}}</td>
            <td>{{customer.id}}</td>
            <td>{{customer.transaction_date | date}}</td>
        </tr>
    </tbody>
</table>