2016-09-18 146 views
0

我從mysql數據庫中獲取以下數據,其中「comment」來自一個表,「blog」是另一個表。現在我想通過ng-repeat在視圖中顯示這些數據。如何從包含json數組的json對象在angularjs中獲取特定值

{ 
    "comment":[ 
    {"comment_id":"3","blog_id":"1","total_comment":"2"}, 
    {"comment_id":"9","blog_id":"8","total_comment":"3"} 
    ], 
    "blog":[ 
    {"id":"9","title":"jquery","description":"this is about jquery","date":"2016-08-27","status":"active"}, 
    {"id":"8","title":"javascript","description":"this is javascript post","date":"0000-00-00","status":"active"}, 
    {"id":"1","title":"angularjs","description":"this blog is about angularjs.this blog is about angularjs.this blog is about angularjs.this blog is about angularjs.this blog is about angularjs.this blog is about angularjs.","date":"2016-07-12","status":"active"} 
    ] 
} 
+1

那麼你嘗試過什麼? – RiggsFolly

+0

{{result.comment.total_comment}} and {{result.blog.title}}

+0

我現在已經得到了迴應的數據如何訪問我需要的特定記錄 –

回答

0

如果相信「blog_id」是博客表和評論表之間的共同字段。

寫聯接查詢在MySQL「ON blog.id = comment.blog_id」,讓你得到你想要的數據,你可能會顯示在響應NG-重複