title: Iterate JSON response from API using AngularJS ngResponse
body: <p>I'm taking my first steps with AngularJS calling an API that would send back a JSON object with the data that I need.  I calls the API and takes the response and print it on the HTML, iterating as needed.</p>
  
  <p>But I haven't found a way on the actual Javascript file, to iterate to lets say, group and sum items, or to print the actual values of the JSON to the console.</p>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>    angular.module('dashboard', ['ngResource']);
      function DashboardCtrl($scope, $resource) {
          $scope.dailyReports = $resource('http://myurl.com/app_dev.php/:action',
              {action:'dailyreports', appid:'@appid', begindate:'@begindate', enddate:'@enddate'});
  
  
      $scope.loadData = function() {
              $scope.dailyreportsResults = $scope.dailyReports.get({appid:$('#sel-apps').val(), begindate:$('#fecha-inicial').val(), enddate:$('#fecha-final').val()});
  //it works!!!!
          };
  
  $scope.iterate = function() {
  
              for (i=0; i &lt; $scope.dailyreportsResults.data.length; i++){
                      $scope.periodUnits += $scope.dailyreportsResults.data[i].units;
                      console.log($scope.periodUnits);
                      //It doesnt work :(
  
              }
      };
  </code></pre>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>ng-repeat="data in dailyreportsResults.data"
     {{data.countryName}}
     {{data.units}}
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks guys!</p>