title: How to count child elements in angularfire?
body: <p>Hi I am using angularfire for my app 
  I am listing my service and controller here. I am planning to get the count of comments which has been added to a particular post. this is my controller </p>
  
  <pre><code>    app.controller('PostViewCtrl', function ($scope,                          
       FIREBASE_URL,$routeParams,  
       Post, Auth, $timeout,$interval,$http, $rootScope, $firebase) {
  
      var ref = new Firebase(FIREBASE_URL);
      $scope.post = Post.get($routeParams.postId);
      $scope.comments = Post.comments($routeParams.postId);
  
  
        $scope.user = Auth.user;
        $scope.signedIn = Auth.signedIn;
  
  
              $scope.addComment = function () {
           if(!$scope.commentText || $scope.commentText === '') {
           return;
             }
             var Commentcreatedtime = moment().format('llll');
             $scope.CommentcreatedTime = Commentcreatedtime;
        var comment = {
    createdTime:  $scope.CommentcreatedTime,
    text: $scope.commentText,
    creator: $scope.user.profile.username,
    creatorUID: $scope.user.uid,
    creatorpic: $scope.user.profile.userpic,
    commentimage: $scope.object.image.info.uuid
  };
  
  
  $scope.comments.$add(comment);
  
  
  
  
  $scope.commentText = '';
  $scope.object.image.info.uuid = '';
     };
  
      });
  </code></pre>
  
  <p>this is my service </p>
  
  <pre><code>   'use strict';
  
     app.factory('Post', function($firebase,FIREBASE_URL){
  
     var ref = new Firebase(FIREBASE_URL);
      var posts = $firebase(ref.child('posts')).$asArray();
  
       var Post = {
      all: posts,
      create: function(post){
      return posts.$add(post).then(function(postRef){
          $firebase(ref.child('user_posts').child(post.creatorUID))
                      .$push(postRef.name());
          return postRef;
       });
        },
       get: function(postId){
      return $firebase(ref.child('posts').child(postId)).$asObject();
  
       },
        delete: function(post){
      return posts.$remove(post);
         },
     comments: function(postId){
  
       return $firebase(ref.child('comments').child(postId)).$asArray();
         }
        };
  
          return Post;
  
        });
  </code></pre>
  
  <p>I have tried using transaction to update a counter on the addComment event like this </p>
  
  <pre><code>   $scope.comments.$add(comment, function(error) {
      if (!error) {
       $firebase(ref.child('comments').child(postId)
       .child('commentcount')).transaction(function (count) {
        return count + 1;
      });
       }
      });
  </code></pre>
  
  <p>but this does not create a child to comments-- postId nor is there a counter. Please do help me. I am new to firebase and angular and your help will be much appreciated. </p>