【发布时间】:2015-01-23 10:05:10
【问题描述】:
我正在托管一个公开 REST API 的 Web 服务器。以下是我从服务器获得的 JSON 响应。
[
{
"score": 4,
"sense": "be the winner in a contest or competition; be victorious; \"He won the Gold Medal in skating\"; \"Our home team won\"; \"Win the game\""
},
{
"score": 2,
"sense": "win something through one's efforts; \"I acquired a passing knowledge of Chinese\"; \"Gain an understanding of international finance\""
},
{
"score": 0,
"sense": "obtain advantages, such as points, etc.; \"The home team was gaining ground\"; \"After defeating the Knicks, the Blazers pulled ahead of the Lakers in the battle for the number-one playoff berth in the Western Conference\""
},
{
"score": 4,
"sense": "attain success or reach a desired goal; \"The enterprise succeeded\"; \"We succeeded in getting tickets to the show\"; \"she struggled to overcome her handicap and won\""
}
]
我想在列表中显示这个。我正在以下列方式使用材料设计:
<md-list data-ng-repeat="item in sensesscores track by $index">
<md-item-content>
<div class="md-tile-content">
{{item.sense}}
</div>
<div class="md-tile-left">
{{item.score}}
</div>
</md-item-content>
</md-list>
在我的控制器中,我有以下内容:
$http.get('http://localhost:8080/nlp-wsd-demo/wsd/disambiguate').
success(function(data) {
$scope.sensesscores = data;
console.log(data);
});
我确保我能够获取“sensesscores”中的数据并将其打印在屏幕上。但是,我无法进行解析并将其显示在列表中。提前致谢。
编辑
我更改了代码以更正语法并将 ng-repeat 向上移动层次结构,但它仍然不起作用。但是,我在另一个 JSON 文件上进行了尝试,该文件有效。
[{
"sense": "sensaS,NF,ASNGD.,AD., BVAS.,GMDN,FG e1",
"score" : 5
},
{
"sense": "sen ASG SFG S H D GD FJDF JDF J GFJ FDFGse2",
"score" : 13
}
,
{
"sense": "sen ASG SFG S H D GD FJDF JDF J GFJ FDFGse2",
"score" : 1
},
{
"sense": "sen ASG SFG S H D GD FJDF JDF J GFJ FDFGse2",
"score" : 0
},
{
"sense": "sen ASG SFG S H D GD FJDF JDF J GFJ FDFGse2",
"score" : 3
},
{
"sense": "sen ASG SFG S H D GD FJDF JDF J GFJ FDFGse2",
"score" : 2
},
{
"sense": "sen ASG SFG S H D GD FJDF JDF J GFJ FDFGse2",
"score" : 1
}
]
我不明白 JSON 响应有什么问题。
【问题讨论】:
-
我想指出,ng-repeat 应该在项目项目之上的层次结构中,它们永远不会以这种方式显示,将它们向下移动一级