title: AngularJS: Send $http.get requests continuously until certain condition
body: <p>As the title says, I want to send $http.get requests to the server until the returned results meets a condition.</p>
  
  <p>This is what I tried:</p>
  
  <pre><code>    var searchComplete = false;
      var sendGetReq = true;
  
      while(!searchComplete) // #2 and then jumps here
      {
         if(sendGetReq)
         {
           sendGetReq = false;  // #1 execution reaches here
           $http.get('/user/getCondition', {params: {condition: $scope.condition}).
          success(function (condition, status, headers, config) {
           ...
           ...
           if(condition)
           { searchComplete = true; }
           else
           { sendGetReq = true; }
      }
  }
  </code></pre>
  
  <p>However, the $http.get request never goes. That statement is never reached. When I debugged, I saw that execution will come to <code>sendGetReq=false</code> and then jump to <code>while(!searchComplete)</code>. The GET request is never sent.</p>
  
  <p>Would someone please explain:</p>
  
  <ol>
  <li>Why the execution never reaches GET request and jumps back</li>
  <li>What is the recommended way to to do this continuous GET request</li>
  </ol>
  
  <p>Thank you.</p>