【发布时间】:2015-07-03 09:51:50
【问题描述】:
一切正常,但是当没有其他数据时,我会得到额外的 5 行空数据:
例子:
2015 年 4 月 25 日星期六,美国纽约麦迪逊广场花园 弗拉基米尔克里琴科 63 与科比詹宁斯 19 对比 对比 对比 对比 对比 2015 年 5 月 9 日,星期六,美国德克萨斯州休斯顿,Minute Maid Park 詹姆斯柯克兰 32 对索尔阿尔瓦雷斯 44 对比 对比 对比 对比 对比我的 JS:
function WidgetCtrl($scope, $http) {
$scope.items = [];
$http.jsonp("http:/domain.com/schedule?callback=JSON_CALLBACK").success(function(data)
{
$scope.items = data;
}).error(function(data, status, headers, config) {
$scope.status = status;
});
}
index.html
<div id="widget-content" ng-controller="WidgetCtrl">
<div ng-repeat="item in items">
{{item.searchdate}} {{item.event_place}}
<div class="widget-list">
<div ng-repeat="name in item">
{{name.boxer1_name}} {{name.boxer1_w}} vs {{name.boxer2_name}} {{name.boxer2_w}}
</div>
</div>
</div>
</div>
JSON:
[
{
"event_id":"1821",
"searchdate":"Sat, Apr 25 2015",
"event_place":"Madison Square Garden, New York, New York, USA",
"networks":"TV: HBO Boxing",
"time":"Time: 9pm Et",
"0":{
"match_id":"5068",
"match_name":"Heavyweight",
"mainevent":"main",
"body":"",
"boxer1_id":"7",
"boxer1_name":"Wladimir Klitschko",
"boxer1_w":"63",
"boxer1_l":"3",
"boxer1_d":"0",
"boxer1_ko":"53",
"boxer2_id":"2780",
"boxer2_name":"Bryant Jennings",
"boxer2_w":"19",
"boxer2_l":"0",
"boxer2_d":"0",
"boxer2_ko":"10"
}
},
{
"event_id":"1853",
"searchdate":"Sat, May 09 2015",
"event_place":"Minute Maid Park, Houston, Texas, USA",
"networks":"TV: HBO",
"time":"Time: 9pm ET",
"0":{
"match_id":"5127",
"match_name":"super welterweight",
"mainevent":"main",
"body":"",
"boxer1_id":"233",
"boxer1_name":"James Kirkland",
"boxer1_w":"32",
"boxer1_l":"1",
"boxer1_d":"0",
"boxer1_ko":"28",
"boxer2_id":"1336",
"boxer2_name":"Saul Alvarez",
"boxer2_w":"44",
"boxer2_l":"1",
"boxer2_d":"1",
"boxer2_ko":"31"
}
}
]
【问题讨论】:
-
这里没有足够的细节和数据来提供帮助。发布的 JSON 数据显然不是提供示例的数据,因此它并没有真正的帮助。重现正在发生的事情的 plnkr 将是最有帮助的。
-
发布的json数据是提供示例的数据。我保证。
-
当我第一次查看时,显示了 8 个拳击手,而 JSON 数据是一行仅显示 1 个拳击手,所以上面的数据自从我第一次查看以来就发生了变化。
-
是的。我有两个提要,一个是完整的战斗卡,另一个是主要事件。对不起。然而,这都是同一个问题。