如何从包含json数组的json对象在angularjs中获取特定值
问题描述:
我从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"}
]
}
答
如果相信“blog_id”是博客表和评论表之间的共同字段。
写联接查询在MySQL“ON blog.id = comment.blog_id”,让你得到你想要的数据,你可能会显示在响应NG-重复
那么你尝试过什么? – RiggsFolly
我现在已经得到了回应的数据如何访问我需要的特定记录 –