title: Angular JS - Running two functions in one controller
body: <p>I'm fairly new to AngularJS so apologies in advance.</p>
  
  <pre><code>var tcores = 0;
  
  angular.module('core').controller('HomeController', ['$scope', '$http',
    function($scope, $http) {
      $http.get('search?idc=LH5&amp;type=Virtual&amp;cluster=1').success(function(data) {
        $scope.servers = data; // get data from json
        angular.forEach($scope.servers, function(item){
          //console.log(item.cores);
          if(parseInt(item.cores) != "NaN" &amp;&amp; item.cores != "") {
            if(angular.isNumber(parseInt(item.cores))) {
              tcores = parseInt(tcores) + parseInt(item.cores);
            }
          }
        })
        console.log("Hall 5. Cluster 1 Total Cores: " + tcores);
      });
    }
  ]);
  
  angular.module('core').controller('HomeController', ['$scope', '$http',
    function($scope, $http) {
      $http.get('search?idc=LH5&amp;type=Virtual&amp;cluster=2').success(function(data2) {
        $scope.serverscluster = data2; // get data from json
        angular.forEach($scope.serverscluster, function(item){
          //console.log(item.cores);
          if(parseInt(item.cores) != "NaN" &amp;&amp; item.cores != "") {
            if(angular.isNumber(parseInt(item.cores))) {
              tcores = parseInt(tcores) + parseInt(item.cores);
            }
          }
        })
        console.log("Hall 5. Cluster 2 Total Cores: " + tcores);
      });
    }
  ]);
  </code></pre>
  
  <p>I'm trying to run both functions (both are pointed at different JSON outputs), however I am only receiving a response for "cluster 2".</p>
  
  <p>Please advise how I can run both functions in the same module, ideally I will be running 8 of these requests on the same page so advice is most appreciated.#</p>
  
  <p>Can you also tell my <strong>why</strong> only the bottom function is executing?</p>
  
  <p>Thank you very much!</p>