简体   繁体   中英

how to get specific value from json object which contains json array in angularjs

i get the following data from mysql data base where "comment" is from one table and "blog" is another table . now i want to show this data in view through ng-repeat.

{
  "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"}
  ]
}

If believe "blog_id" is the common field between the blog table and the comment table.

Write a Join query in mysql "ON blog.id = comment.blog_id" so that you get the data you wanted and you may display the response in ng-repeat

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM