angular - 使用 2 个 json 的 Angular ngprime 表
问题描述
我是 ngprime 的新手,面临以下问题。我得到 2 个 json 用于第一列的标签,第二个 json 有第二列和第三列的数据。第二列和第三列的数据需要根据 json 1 中的 id 显示。例如。json 一个具有 id firstName 和 displayname 作为 Firstname。我需要从 json 1 中引用 id 并在 json 2 中搜索相同的 id 并在第 2 列和第 3 列中显示值。
我想使用 ngPrime p-table 来实现这一点,甚至无法启动。下面是要使用的json和要实现的输出。
我尝试搜索类似的问题,但没有任何帮助。请帮我举个例子
var json1 = [
{id:'firstName', displayname:'First Name'},
{id:'lastName', displayname:'Last Name'},
{id:'age', displayname:'Age'},
{id:'city', displayname:'City'},
{id:'state', displayname:'State'}
];
var json2 = [
{'firstName':'abc', 'age': 23, 'state':'MH', 'lastName': 'sharma', 'city': 'Mumbai'},
{'firstName':'xyz', 'age': 35, 'state':'TL', 'lastName': 'Verma', 'city': 'Hyderabad'}
];
<!-- Need output as below using ngPrime <p-table><p-table> -->
<table border="1">
<thead>
<tr>
<th>Description</th>
<th>Record 1</th>
<th>Record 1</th>
</tr>
</thead>
<tbody>
<tr>
<td>First Name</td>
<td>abc</td>
<td>xyz</td>
</tr>
<tr>
<td>Last Name</td>
<td>sharma</td>
<td>verma</td>
</tr>
<tr>
<td>Age</td>
<td>23</td>
<td>35</td>
</tr>
<tr>
<td>City</td>
<td>Mumbai</td>
<td>Hyderabad</td>
</tr>
<tr>
<td>State</td>
<td>MH</td>
<td>TL</td>
</tr>
</tbody>
</table>
解决方案
推荐阅读
- python-3.x - Treeview 可以突出显示选定的列吗?
- r - 关于 Stan 代码中多级逻辑模型(混合截距逻辑模型)的问题
- javascript - 两页条件图像分类(MTurk)
- sql - 范围内未找到 H2 SQL 查询列
- c# - 使用 System.Buffers.ArrayPool 的池化数组损坏
- python - Pandas.Series.unique() 丢弃唯一值
- html - 如何在 django 中将完整的 html 页面制作为 pfd
- c - 我无法使用 fscanf 将文件中的数据加载到结构中
- amazon-web-services - AWS Media Live - 处理流开始和停止事件
- python - 了解 Pytorch 过滤器功能