我有以下JSON:
{ "ListNhomThanhTra": [
{
"ListKeHoachThanhTra": [
{
"ListDoiTuong": [
{
"MA_DV_DUOC_TT": "DT01",
"TEN_DOITUONG": "Tỉnh Bắc Ninh",
"stt": 1.1
}
],
"MA_DM_KEHOACH_TT": "KH13072018003",
"TEN_KEHOACH": "Kế hoạch chính thức",
"stt": 1
}
],
"MA_NHOM_TT": "010",
"TEN_NHOM": "Thanh tra ngân sách địa phương",
"stt": "I"
},
{
"ListKeHoachThanhTra": [
{
"ListDoiTuong": [
{
"MA_DV_DUOC_TT": "DT01",
"TEN_DOITUONG": "Tỉnh Bắc Ninh",
"stt": 1.1
}
],
"MA_DM_KEHOACH_TT": "KH13072018003",
"TEN_KEHOACH": "Kế hoạch chính thức",
"stt": 1
}
],
"MA_NHOM_TT": "02",
"TEN_NHOM": "Thanh tra tài chính, bộ ngành",
"stt": "II"
}
],
"MA_LOAI_TT": "01",
"TEN_LOAI": "Kế hoạch thanh tra",
"stt": "A"
}
当前,我有一个像这样的JSON字符串,我想以表格形式显示它。
我尝试使用下面的代码,但是它仅在第二个ng-repeat处停止,并且不再进行下去,所以我想知道如何正确执行此操作?
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<tbody ng-repeat="loaiThanhTra in dataTable">
<td>{{loaiThanhTra.stt}}</td>
<td>{{loaiThanhTra.TEN_LOAI}}</td>
<tr ng-repeat="nhomThanhTra in loaiThanhTra.ListNhomThanhTra">
<td>{{nhomThanhTra.stt}}</td>
<td>{{nhomThanhTra.TEN_NHOM}}</td>
<tr ng-repeat="keHoachThanhTra in nhomThanhTra.ListKeHoachThanhTra ">
<td>{{keHoachThanhTra.stt}}</td>
<td>{{keHoachThanhTra.TEN_KEHOACH}}</td>
<tr ng-repeat="doiTuongThanhTra in keHoachThanhTra.ListDoiTuong">
<td>{{doiTuongThanhTra.stt}}</td>
<td>{{doiTuongThanhTra.TEN_DOITUONG}}</td>
</tr>
</tr>
</tr>
</tbody>
请帮助我!
答案 0 :(得分:0)
tds中不能包含trs。在父对象上使用ng-container和行跨度。
<tbody ng-repeat="loaiThanhTra in dataTable">
<td>{{loaiThanhTra.stt}}</td>
<td>{{loaiThanhTra.TEN_LOAI}}</td>
<tr ng-repeat="nhomThanhTra in loaiThanhTra.ListNhomThanhTra">
<td rowspan="nhomThanhTra.ListKeHoachThanhTra.length">{{nhomThanhTra.stt}}</td>
<td rowspan="nhomThanhTra.ListKeHoachThanhTra.length">{{nhomThanhTra.TEN_NHOM}}
</td>
<ng-container ng-repeat="keHoachThanhTra in nhomThanhTra.ListKeHoachThanhTra ">
<td rowspan="keHoachThanhTra.ListDoiTuong.length">{{keHoachThanhTra.stt}}</td>
<td rowspan="keHoachThanhTra.ListDoiTuong.length">{{keHoachThanhTra.TEN_KEHOACH}}</td>
<ng-container ng-repeat="doiTuongThanhTra in keHoachThanhTra.ListDoiTuong">
<td>{{doiTuongThanhTra.stt}}</td>
<td>{{doiTuongThanhTra.TEN_DOITUONG}}</td>
</ng-container>
</ng-container>
</tbody>