2015-01-23 3 views
0

나는 REST API를 노출하는 웹 서버를 호스팅하고 있습니다. 다음은 서버에서 얻은 JSON 응답입니다.Angularjs 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\"" 
    } 
] 

목록에 표시하고 싶습니다. 나는 다음과 같은 방법으로, 재료 디자인을 사용하고 있습니다 :

$http.get('http://localhost:8080/nlp-wsd-demo/wsd/disambiguate'). 
     success(function(data) { 
      $scope.sensesscores = data; 
      console.log(data); 
     }); 

은 내가 'sensesscores'에서 데이터를 얻을 수 있어요 있는지 만들어 :

내 컨트롤러에서
<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> 

, 나는 다음과 같은이 그것을 화면에 인쇄했습니다. 그러나 구문을 분석하여 목록을 표시 할 수는 없습니다. 미리 감사드립니다.

편집


나는 구문을 해결하기 위해 코드를 변경하고, NG-반복 계층 구조를하지만,이 아직도 나던 작업을 이동. 그러나, 나는 작동하는 다른 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 응답의 문제점을 이해하지 못합니다.

<md-list> 
    <md-item 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> // this tag was not closed, but rather a new opener 
    </md-item> 
</md-list> // this tag was not closed properly, missing ">" 

변경을하고, 예상대로 데이터가 표시됩니다 :

+0

ng-repeat는 항목 항목 위의 계층 구조에서 한 수준이어야하며 표시되지 않습니다. 이런 식으로 한 수준 아래로 움직이십시오. – pfried

답변

0

나는 해결책을 찾아 냈다. 내용을 json 객체로 변환해야하고 jquery를 사용하여 작성했습니다. - $ .parseJSON (data)

0

귀하의 HTML은 아래의 형식이 올바르게되어, 많은 오타가 있습니다.