Javascript 角度js中的动态列表+;类型脚本
我想使用anguler js创建以下动态列表 根据my的要求,列集(如水果、蔬菜)可以根据数据集进行动态更改。我想从json文件加载数据。 例:Javascript 角度js中的动态列表+;类型脚本,javascript,angularjs,json,typescript,angular2-directives,Javascript,Angularjs,Json,Typescript,Angular2 Directives,我想使用anguler js创建以下动态列表 根据my的要求,列集(如水果、蔬菜)可以根据数据集进行动态更改。我想从json文件加载数据。 例: 我尝试了许多方法,但无法创建动态表。如何创建这种类型的表?您需要使表结构如下: <table border="1" cellpadding="10" cellspacing="0"> <thead> <tr> <th rowspan="2">Store</th> <
我尝试了许多方法,但无法创建动态表。如何创建这种类型的表?您需要使表结构如下:
<table border="1" cellpadding="10" cellspacing="0">
<thead>
<tr>
<th rowspan="2">Store</th>
<th rowspan="2">Store Name</th>
<th colspan="4">Vegetables</th>
<th colspan="4">Fruit</th>
</tr>
<tr>
<th>Ordered</th>
<th>Delivery</th>
<th>FR</th>
<th>Gap</th>
<th>Ordered</th>
<th>Delivery</th>
<th>FR</th>
<th>Gap</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of items">
<td>item.storeCode</td>
<td>item.storeName</td>
<td>item.Vegetables.Ordered</td>
<td>item.Vegetables.Delivery</td>
<td>item.Vegetables.FR</td>
<td>item.Vegetables.Gap</td>
<td>item.Fruit.Ordered</td>
<td>item.Fruit.Delivery</td>
<td>item.Fruit.FR</td>
<td>item.Fruit.Gap</td>
</tr>
</tbody>
商场
店名
蔬菜
果
命令
传送
FR
缺口
命令
传送
FR
缺口
item.storeCode
item.storeName
点的菜
项目.蔬菜.交货
item.vegets.FR
项目.蔬菜.缺口
点了水果
项目.水果.交货
item.Fruit.FR
项目.水果.缺口
您可以看到正在运行的jsBin谢谢@Rohit Sharma。但当另一个类别(如水果)可用时会发生什么。根据上述结构,我们必须更改代码。然后您需要将类别存储在数组中,并相应地生成动态标题。如果您希望有人能够回答您的问题,您需要显示您尝试了什么以及失败的地方。你的问题有点太大了,如果你想让别人花时间回答你,你需要更具体一点,否则,没人知道从哪里开始。
<table border="1" cellpadding="10" cellspacing="0">
<thead>
<tr>
<th rowspan="2">Store</th>
<th rowspan="2">Store Name</th>
<th colspan="4">Vegetables</th>
<th colspan="4">Fruit</th>
</tr>
<tr>
<th>Ordered</th>
<th>Delivery</th>
<th>FR</th>
<th>Gap</th>
<th>Ordered</th>
<th>Delivery</th>
<th>FR</th>
<th>Gap</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of items">
<td>item.storeCode</td>
<td>item.storeName</td>
<td>item.Vegetables.Ordered</td>
<td>item.Vegetables.Delivery</td>
<td>item.Vegetables.FR</td>
<td>item.Vegetables.Gap</td>
<td>item.Fruit.Ordered</td>
<td>item.Fruit.Delivery</td>
<td>item.Fruit.FR</td>
<td>item.Fruit.Gap</td>
</tr>
</tbody>