【问题标题】:Display Array<Object> in PrimeNg template在 PrimeNg 模板中显示 Array<Object>
【发布时间】:2017-10-21 18:19:25
【问题描述】:

我有这种 JSON:

    {
       description: "Some Description",
       child: [{
          description2: "Some Other Description",
          description3: "Another Description"
       }]

    }

我想在我的 PrimeNg DataTable 上显示它,但不知何故它总是显示空白单元格。

这是我的专栏代码

    <p-column field="child" header="Child">
      <ng-template let-col let-item="rowData" pTemplate="body" >
        <tr ngFor="let child of item.child">
          <td>
            {{child.description2}}
          </td>
        </tr>
      </ng-template>
    </p-column>

有什么解决办法吗?

【问题讨论】:

    标签: angular angular2-template primeng angular-datatables


    【解决方案1】:

    经过一些尝试,我找到了解决方案,这是我的答案:

        <p-column>
          <ng-template pTemplate="header">Child</ng-template>
          <ng-template let-col let-childs="rowData.child" pTemplate="body" >
            <tr *ngFor="let child of childs">
              <td>{{child.description2}}</td>
            </tr>
          </ng-template>
        </p-column>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-30
      • 1970-01-01
      • 2018-06-12
      • 1970-01-01
      • 2017-08-07
      • 2019-11-23
      • 1970-01-01
      • 2020-10-10
      相关资源
      最近更新 更多