title: How to always run some code when a promise is fulfilled in Angular.js
body: <p>In my Angular.js application, I'm running some asynchronous operation. Before it starts I cover the application with a modal div, then once the operation is complete, I need to remove the div, whether the operation was successful or not.</p>
  
  <p>Currently I have this:</p>
  
  <pre class="lang-js prettyprint-override"><code>LoadingOverlay.start(); 
  Auth.initialize().then(function() {
      LoadingOverlay.stop();
  }, function() {
      LoadingOverlay.stop(); // Code needs to be duplicated here
  })
  </code></pre>
  
  <p>It works well, however I would prefer to have something cleaner like this pseudo-code:</p>
  
  <pre class="lang-js prettyprint-override"><code>LoadingOverlay.start(); 
  Auth.initialize().finally(function() { // *pseudo-code* - some function that is always executed on both failure and success.
      LoadingOverlay.stop();
  })
  </code></pre>
  
  <p>I assume it's quite a common problem, so I was thinking it could be done but cannot find anything in the doc. Any idea if it can be done?</p>