title: AngularJS modal async close doesn't work
body: <p>I am creating a modal and closing it once data comes in the background. </p>
  
  <pre><code>var modal = modal.open({..some params..});
  
  //after data loads
  modal.close();
  </code></pre>
  
  <p>So my problem is, since everything is asynchronous if my data comes instantaneously then my modal.close() executes before modal opens fully and then my screen remains stuck with the modal screen.</p>
  
  <p>One solution I found is adding a timeout to the modal.close</p>
  
  <pre><code>$timeout(function() {
   modal.close();
  }, 1)
  </code></pre>
  
  <p>This works but is it the right way to do it? Or there is some other better solution?</p>