title: Angular JS infinite loop on checkbox ng-click with $http request
body: <p>I have a problem with infinite loop on $http request. Somehow it goes to infinite only on checkbox, because I`m changing the model value of variable, attached to this checkbox. Here is the code:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;div ng-repeat="contract in contracts"&gt;
        &lt;select ng-model="contract.name" ng-change="getTransliteratedMessage()"/&gt;
        &lt;div ng-repeat="additionalContract in contract.additionalContracts"&gt;
            &lt;input type="text" ng-model="additionalContract.name"/&gt;
            &lt;input type="checkbox" id="myCheckbox" ng-model="additionalContract.isMessage" ng-click="getTransliteratedMessage()"/&gt;
            &lt;label for="myCheckbox"&gt;Some msg&lt;/label&gt;
        &lt;/div&gt;
  &lt;/div&gt;
  &lt;textarea ng-model="transliteratedText"/&gt;
  </code></pre>
  
  <p>and here is controller method:</p>
  
  <pre class="lang-js prettyprint-override"><code>$scope.getTransliteratedMessage = function() {
     var transliterationPromises = [];
     angular.forEach($scope.contracts, function(contract) {
         transliterationPromises.push($http({method: 'GET', url: 'some/url', params: contract.name});
         angular.forEach(contract.additionalContracts, function(addContract) {
             if (addContract.isMessage) {
                  transliterationPromises.push($http({method: 'GET', url: 'some/url', params: addContract.name});
             }
         });
     });
     $q.all(transliterationPromises).then(function(results) {
         angular.forEach(results, function(result) {
             $scope.transliteratedText = $scope.transliteratedText + ' ' + result.data;
         }
     }
  }
  </code></pre>
  
  <p>So, here is the problem - when I change the first contract &lt; select > element - it completes the transliteration method perfectly. But when I click on checkBox of additionalContract - it goes to infinite loop. I tried workaround with $timeout - didn't help, tried to prevent double-click with label problem - didn't help. There is some solution to this $rootScope.$apply which is being fired on each $http request. Maybe you can help?</p>