简体   繁体   English

通过angularjs中的父帖子ID显示评论

[英]Show comment through parent post id in angularjs

I am creating wall script like facebook. 我正在创建Facebook之类的墙脚本。 I am new in Angularjs. 我是Angularjs的新手。 My problem is I am showing all post from database through controller which is display fine. 我的问题是我正在通过控制器显示数据库中的所有帖子,显示效果很好。 Now I have to show that post comments below parent post. 现在,我必须在父帖子下方显示该帖子评论。 I am using ng-repeat="comment in comments" for this but now all comment repeat in all post. 我为此使用ng-repeat =“评论中的评论”,但现在所有评论都在所有帖子中重复。

Can you tell me show to display comments data according to parent id? 您能告诉我show根据父ID显示评论数据吗?

This is my code: 这是我的代码:

commentlist:function(data,scope)
        {

                var dataObject = {
          communityid : data
       };
            $http.post(ApiAccessUrl+"/community/commentlist/DADA-APIKEY/"+APIKEY, dataObject, {})
         .success(function(data){

               angular.forEach(data.commentlist, function(value, key) {
                   var dataObject = {
          timestamp : value.comment_date_time
       };

                   $http.post(ApiAccessUrl+"/community/timestamp/DADA-APIKEY/"+APIKEY, dataObject, {})
         .success(function(data){ 
          var outputDate=angular.fromJson(data);
           var full_name=ucfirst(value.mem_fname)+" "+ucfirst(value.mem_lname); 

              var photo='value.photo;
                scope.comments.unshift({full_name:full_name,photo:photo,comment:value.comment_comment,timestamp:outputDate});
         });

if comment has postId, then you can do ng-repeat like this 如果评论具有postId,那么您可以像这样进行ng-repeat

<div ng-repeat="post in posts"> 
    <div ng-repeat="comment in comments | filter : {'postId' : post.Id }"> 
       <a href="" class="size13">{{comment.full_name}}</a> 
       <span class="size12"> {{comment.comment}} </span> 
    </div>
</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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