title: After Angular.js $http request, call complete function regardless of success or failure of promise
body: <p>How can I ensure that the <code>complete()</code> function will run regardless of the outcome of the $http call using the promise API provided with Angular.js?</p>
  
  <pre><code>$http({
      method: 'POST',
      url: submitUrl,
      data: $scope.data
  })
  .success(function(data) {
        // execute this code on success
  })
  .error(function(data) {
        // execute this code on error
  })
  .complete(function() {
    // execute this code regardless of outcome
  });
  </code></pre>
  
  <p>One could use this to hide an AJAX spinner icon once the request is complete. You would want to hide the spinner regardless of the request outcome.</p>