【发布时间】:2017-05-25 03:17:03
【问题描述】:
我正在尝试将下面的 json 加载到primeng数据表中。我在设置列名时遇到问题
[
{
"accountId": 1,
"accountName": "Environmental Service Ltd",
"addressBook": {
"addressBookId": 1,
"companyId": 1,
"addressList": [
{
"addressLine1": "ABC",
"addressLine2": "XYZ",
"addressLine3": "TUV",
"city": "ALY",
"postCode": "AB9 7RT"
}
]
}
}
]
我的代码在这里
<p-dataTable #dtAccounts [value]="accounts">
<p-header>Accounts</p-header>
<p-column field="accountName" header="Account Name" [sortable]="true"></p-column>
<p-column field="telephone" header="Account Phone" [sortable]="true"></p-column>
<p-column field="addressLine1" header="Street"></p-column>
<p-column field="city" header="City"></p-column>
<p-column field="state" header="State/Province"></p-column>
<p-column field="postCode" header="Zip/Postal Code"/>
</p-dataTable>
【问题讨论】:
-
您面临的具体问题是什么?您是指“accountName”列吗?
-
这是错误的:
<p-column field="postCode" header="Zip/Postal Code"/>,应该是:<p-column field="postCode" header="Zip/Postal Code"></p-column>但它仍然只会根据 JSON 的样子填充表中的accountName。