我想创建html表。我使用AngularJs指令 - ng-repeat。我有从服务器加载的数据。数据类型是text / json。我的Json结构在下面
String jsonResult = db.getResult(keyword);
if (jsonResult == null) {
jsonResult = runSearch(keyword);
}
final String finalJsonResult = jsonResult;
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent newActivity = new Intent(ResultsActivity.this, MoviePage.class);
newActivity.putExtra("index", position);
newActivity.putExtra("json result", finalJsonResult); // Note use of "final" copy
startActivity(newActivity);
}
});
我试图创建表体,但它不起作用。我没有结果。
[
{
"branch":"wdads",
"name":"STANDART",
"Tags":[
],
"Rooms":[
{
"roomNo":"11",
"branch":"wdads",
"Schedule":[
{
"id":"",
"status":"free",
"currentDate":"2015-10-31T20:00:00.000Z"
},
{
"id":"",
"status":"free",
"currentDate":"2015-10-31T20:00:00.000Z"
}
]
}
]
},
{
"branch":"wdads",
"name":"VIP",
"Tags":[
],
"Rooms":[
{
"roomNo":"1",
"branch":"wdads",
"Schedule":[
{
"id":"",
"status":"free",
"currentDate":"2015-12-29T20:00:00.000Z"
},
{
"id":"",
"status":"free",
"currentDate":"2015-12-29T20:00:00.000Z"
}
]
},
{
"roomNo":"2",
"branch":"wdads",
"Schedule":[
{
"id":"",
"status":"free",
"currentDate":"2015-12-29T20:00:00.000Z"
},
{
"id":"",
"status":"free",
"currentDate":"2015-12-29T20:00:00.000Z"
}
]
}
]
}
]
答案 0 :(得分:1)
基本上你写的html是无效的html。
div
的{{1}},table
,tbody
,thead
元素中,您无法tfoot
个元素,如果您尝试这样做,那么该HTML将被视为无效的HTML。
您可以在表格的tr
/ th
元素中包含该元素。基本上,这些元素用于在表格上显示数据。
要解决问题,你需要做几件事。
td
放在ng-repeat
上,并多次重复tbody
表格。tbody
标记的表格行数据时,您应该使用tr
元素。您直接使用td
时应更改为tr
<强>标记强>
<tr><td ng-bind="$first ?caterory.name : ''"></td><tr>
答案 1 :(得分:1)
做点什么
<tbody>
<tr ng-repeat="caterory in categories">{{caterory.name}}<tr>
<tr ng-repeat="room in caterory.Rooms">
<td>{{room.roomNo}}</td>
<td ng-repeat="schedule in room.Schedule">{{schedule.status}}</td>
</tr>
</tbody>