title: angularjs count duplicate values in array of objects
body: <p>I'm working with AngularJS.
  I have an array of objects like this:</p>
  
  <pre><code> $scope.documents =
     [
          {
              "id": "221",
              "activate": "t"
          },
          {
              "id": "1",
              "activate": "t"        
          },
          {
              "id": "2",
              "activate": "t"        
          },
          {
              "id": "221",
              "activate": "t"        
          },
          {
              "id": "5",
              "activate": "t"        
          },
          {
              "id": "221",
              "activate": "t"        
          },
          {
              "id": "221",
              "activate": "t"        
          },
          {
              "id": "7",
              "activate": "t"        
          },
          {
              "id": "8",
              "activate": "t"        
          },
          {
              "id": "9",
              "activate": "t"        
          },
          {
              "id": "221",
              "activate": "t"        
          }
  
      ]
  </code></pre>
  
  <p>I need an angularjs function to count the number of repeated values in the array of objects.</p>
  
  <p>Something like this:</p>
  
  <pre><code>  $scope.count = function(param) {
  
      angular.forEach($scope.preguntas, function(value, key) {
          if (value.id == param){
          ........
          ........
          }
      });
  
    };
  </code></pre>
  
  <p>but I'm not sure how I can do.</p>
  
  <p>I hope the result is something like this:</p>
  
  <pre><code>count(221);
  5
  </code></pre>
  
  <p>Any of you have any suggestions please?</p>