Angularjs使用json数据创建表Ng Repeat
我是个新手。我的任务是从web服务的JSON数据创建一个html表 JSON数据如下所示:Angularjs使用json数据创建表Ng Repeat,angularjs,json,html-table,angularjs-ng-repeat,Angularjs,Json,Html Table,Angularjs Ng Repeat,我是个新手。我的任务是从web服务的JSON数据创建一个html表 JSON数据如下所示: *-------------------------------* | Time | Name | *-------*-----------------------* | 07:00 | xxxxxxxxxxx | |-------| | | 07:15 | |
*-------------------------------*
| Time | Name |
*-------*-----------------------*
| 07:00 | xxxxxxxxxxx |
|-------| |
| 07:15 | |
|-------|-----------------------|
| 07:30 | xxxxxxxxxxxxxx |
|-------|-----------------------|
插槽长度将告诉我们要合并多少行
表应该如下所示:
*-------------------------------*
| Time | Name |
*-------*-----------------------*
| 07:00 | xxxxxxxxxxx |
|-------| |
| 07:15 | |
|-------|-----------------------|
| 07:30 | xxxxxxxxxxxxxx |
|-------|-----------------------|
我已经编辑了你的json,这是无效的。您可以在js或json对象Validator中看到 工作演示: angular.module'testApp',[].controller'testCtrl',函数$scope{ $scope.items=[ {开始时间:07:00,姓名:xxxxxxxx,时隙:[07:00,07:15]}, {开始时间:07:30,姓名:xxxxxxxx,插槽:[07:30]}]; }; 副上校{ 背景:粉红色; 边框底部:1px点黑色; 填充:2px; } 时间 名称 {{i} {{item.Name}
我已经编辑了你的json,这是无效的。您可以在js或json对象Validator中看到 工作演示: angular.module'testApp',[].controller'testCtrl',函数$scope{ $scope.items=[ {开始时间:07:00,姓名:xxxxxxxx,时隙:[07:00,07:15]}, {开始时间:07:30,姓名:xxxxxxxx,插槽:[07:30]}]; }; 副上校{ 背景:粉红色; 边框底部:1px点黑色; 填充:2px; } 时间 名称 {{i} {{item.Name}
只有一张桌子和rowspan一起做这件事是相当棘手的。您必须使用ng重复开始/结束。我还使用$first跳过嵌套重复的第一行
<table border="1">
<thead>
<tr>
<th>Time</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat-start="item in array">
<td>{{item.Slots[0]}}</td>
<td rowspan="{{item.Slots.length}}">{{item.Name}}</td>
</tr>
<tr ng-repeat="slot in item.Slots" ng-if="!$first" ng-repeat-end>
<td>{{slot}}</td>
</tr>
</tbody>
</table>
只有一张桌子和rowspan一起做这件事是相当棘手的。您必须使用ng重复开始/结束。我还使用$first跳过嵌套重复的第一行
<table border="1">
<thead>
<tr>
<th>Time</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr ng-repeat-start="item in array">
<td>{{item.Slots[0]}}</td>
<td rowspan="{{item.Slots.length}}">{{item.Name}}</td>
</tr>
<tr ng-repeat="slot in item.Slots" ng-if="!$first" ng-repeat-end>
<td>{{slot}}</td>
</tr>
</tbody>
</table>
这不是一个有效的对象或Json向我们展示您尝试了什么以及遇到了什么问题A.B Json编辑。请看一看。@SindhuVinodhini是的,我也编辑过,请看答案:@SindhuVinodhini StackOverflow是为了解决您的疑问,请发布您尝试过的内容和遇到的问题。这不是有效的对象或Json向我们展示您尝试过的内容和遇到的问题a.B Json编辑过的内容。请看一看。@SindhuVinodhini是的,我也编辑过,请看答案:@SindhuVinodhini StackOverflow是用来解决您的疑问的,请发布您尝试过的内容以及您的困境。