title: AngularJS Service duplicate response in controller
body: <p>I'm calling the following service:
  Get accounts details</p>
  
  <p>First piece of code in my controller:</p>
  
  <pre><code>//resp is coming from an $http sync request, above the below request.
      for (var i = 0; i &lt; resp.rows; ++i) { 
           userService.getAccountsBalance($rootScope.userid, resp[i]['Acct_Number']).then(function(data){
  
                  console.log(data.bal) // shows two duplicate balances
              });
      }
  </code></pre>
  
  <p>In my service:</p>
  
  <pre><code>app.service('userService', function($rootScope, $q){
      var deferred = $q.defer();  
  
  
      this.getAccountsBalance = function(userid, accountNum){
          console.log(userid + "    " + accountNum)
          var req = &lt;my $http request&gt;
          req.send().then(function(resp){
              deferred.resolve(resp.responseJSON);        
          }); 
  
          console.log(deferred.promise) //// prints two balances JSON objects with no duplicate
          return deferred.promise; 
      }
  });
  </code></pre>
  
  <p>My question is, I can see that two requests(with different parameter) has been executed in my service, and returning two different balances for two accounts. However, in my controller I get two duplicate results. I only get the last response twice.</p>
  
  <p>I'm pretty sure it has something to do with promises, and I'm still new.</p>