title: Angularjs wait until
body: <p>I have:</p>
  
  <pre><code>$scope.bounds = {}
  </code></pre>
  
  <p>And later in my code:</p>
  
  <pre><code>$scope.$on('leafletDirectiveMap.load', function(){
      console.log('runs');
      Dajaxice.async.hello($scope.populate, {
                  'west' : $scope.bounds.southWest.lng,
                  'east': $scope.bounds.northEast.lng,
                  'north' : $scope.bounds.northEast.lat,
                  'south': $scope.bounds.southWest.lat,
      });
  });
  </code></pre>
  
  <p>The bounds as you can see at the begging they are empty but they are loaded later (some milliseconds) with a javascript library (<a href="http://tombatossals.github.io/angular-leaflet-directive/#!/" rel="noreferrer">leaflet angular</a>). However the <code>$scope.$on(...)</code> runs before the bounds have been set so the <code>'west' : $scope.bounds.southWest.lng,</code> returns an error with an undefined variable.</p>
  
  <p>What I want to do is to wait the bounds (<code>southWest</code> and <code>northEast</code>) to have been set and then run the <code>Dajaxice.async.hello(...)</code>.</p>
  
  <p>So I need something like "wait until bounds are set".</p>