title: AngularJS Counting Number of Specific Items Starting With a Value in JSON Dataset
body: <p>I have a set of JSON data:</p>
  
  <pre><code>"MyMessages": [
          {
              "Code" :  "N101",
              "ID" : "History",
              "Indicator" : "Down",
              "PosChangeMessage" : "test test test test",
              "NegReasonMessage" : "test test test test",
              "Image" : "ImageType.Warning"
          },
  
          {
              "Code" :  "P874",
              "ID" : "History",
              "Indicator" : "Up",
              "NegReasonMessage" : "test test test test",
              "Image" : "ImageType.Ok"
          },
  
          {
              "Code" :  "N85",
              "ID" : "Age",
              "Indicator" : "Down",
              "PosChangeMessage" : "test test test test",
              "Image" : "ImageType.Warning"
          },
  
          {
              "Code" :  "N846",
              "ID" : "Products",
              "Indicator" : "Up",
              "PosChangeMessage" : "test test test test",
              "Image" : "ImageType.Ok"
          },
      ],
  </code></pre>
  
  <p>I can display how many items there are in MyMessages via <code>{{ MyMessages.length }}</code></p>
  
  <p>However what i want to know is how many <code>Code</code> items there starting with P and N.</p>
  
  <p>So, in the example above:</p>
  
  <p>P = 1</p>
  
  <p>N = 3</p>
  
  <p>I can count how many <code>Code</code> elements there are via:</p>
  
  <pre><code>angular.forEach(MyMessages, function(message){
  
     if(message.Code){
         $scope.Number++;
     }
  });
  </code></pre>