亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用材質角度將嵌套的 json 數組顯示到 html 表中

如何使用材質角度將嵌套的 json 數組顯示到 html 表中

瀟湘沐 2023-12-04 19:25:17
我正在嘗試將嵌套的 json 數組顯示到我的材質角度表中。如果我的 json 沒有嵌套數組,我的數據工作正常。杰森{"rows": [    {        "mst": {            "field": "createDate",            "value": "2017-06-02"        },        "gsc": {            "field": "Account/Audit/Creation/Date",            "value": "2017-06-02"        }    },    {        "mst": {            "field": "startDate"        },        "gsc": {            "field": "startDate"        }    },    {        "mst": {            "field": "status",            "value": "ACTIVE"        },        "gscs": [            {                "field": "Account/LineOfBusiness/Type~Status",                "value": "C~A"            },            {                "field": "Account/LineOfBusiness/Type~Status",                "value": "I~A"            }                        ],        "gscvalue": "Active"    },    {        "mst": {            "field": "statusDate"        },        "gsc": {            "field": "statusDate"        }    },    {        "mst": {            "field": "statusReason"        },        "gsc": {            "field": "statusReason"        }    },    {        "mst": {            "field": "deliveryMethod",            "value": "PAPER"        },        "gscs": [            {                "field": "Electronic",                "value": "N"            },            {                "field": "ElectronicOutsourced",                "value": "N"            },            {                "field": "Hardcopy",                "value": "Y"            }        ],        "gscvalue": "Paper"    },    {        "mst": {            "field": "statementFormat",            "value": "Standard"        },        "gsc": {            "field": "?"        }    },    {        "mst": {            "field": "statementLanguagePreference",            "value": "Spanish"        },        "gsc": {            "field": "Account/Language",            "value": "S"        },        "gscvalue": "Spanish"    },
查看完整描述

1 回答

?
慕的地6264312

TA貢獻1817條經驗 獲得超6個贊

似乎你只需要嵌套你的ngIf:


<ng-container matColumnDef="gsc Fields">

  <th mat-header-cell *matHeaderCellDef> gsc Fields </th>

  <td mat-cell *matCellDef="let row">

    <ng-container *ngIf="row.gsc?.field; else fieldArray">

      {{row.gsc.field}} 

    </ng-container>

    <ng-template #fieldArray>

      <div class="sub-cell" *ngFor="let field of row.gscs"> <!-- need the appropriate css -->

        {{field.field}} {{field.value}}

      </div>

    </ng-template>

  </td>

</ng-container>

在你的價值欄中你想要更多類似的:


<ng-container matColumnDef="gsc">

  <th mat-header-cell *matHeaderCellDef> gsc value </th>

  <td mat-cell *matCellDef="let row"> {{row.gsc?.value || row.gscvalue}} </td>           

</ng-container>

不確定這是 100% 但應該很接近


查看完整回答
反對 回復 2023-12-04
  • 1 回答
  • 0 關注
  • 175 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號