title: AngularJS: $http response too slow
body: <p>I am using this code:</p>
  
  <pre><code>$http.get('/api/users').
  success(function(data) {
      $scope.authors = data;
  }).
  error(function() {
      console.log('API error - config.')
  }); 
  </code></pre>
  
  <p>And somewhere below (much bellow):</p>
  
  <pre><code>for (var i = 0; i &lt; $scope.authors.length; i++) {
      ...
  };
  </code></pre>
  
  <p>Sometimes it happens that <code>$scope.authors</code> are not avaliable yet. Is there any way to solve this?</p>
  
  <p><em>UPDATE</em></p>
  
  <p>This is the whole block structure:</p>
  
  <pre><code>// author
  
  $http.get('/api/users').
  success(function(data) {
      $scope.authors = data;
      processAuthors();
  }).
  error(function() {
      console.log('API error - config.')
  });    
  
  // if updating form
  
  $scope.$on('$routeChangeSuccess', function() {
      if($routeParams.id) {
  
          $http.get('/api/offers/' + $routeParams.id).
          success(function(data) {
  
              // author
  
              function processAuthors() {
                  for (var i = 0; i &lt; $scope.authors.length; i++) {
                      if($scope.authors[i].email == data.author.email) {
                          $scope.author = $scope.authors[i];
                      };
                  };                    
              }
  </code></pre>