title: Angularjs Bootstrap modal closing call when clicking outside/esc
body: <p>I am using the <a href="https://github.com/angular-ui/bootstrap" rel="noreferrer">Angular-ui/bootstrap</a> modal in my project.</p>
  
  <p>Here is my modal:</p>
  
  <pre><code>$scope.toggleModal = function () {
      $scope.theModal = $modal.open({
          animation: true,
          templateUrl: 'pages/templates/modal.html',
          size: "sm",
          scope: $scope
      });
  }
  </code></pre>
  
  <p>One is able to close the modal by clicking the <em>ESC</em> button or clicking outside the modal area. Is there a way to run a function when this happens? I am not quite sure how to catch the sort of closing.</p>
  
  <p>I know that I can manually dismiss a modal by having a <code>ng-click="closeModal()"</code> like this:</p>
  
  <pre><code>$scope.closeModal = function () {
      $scope.theModal.dismiss('cancel');
  };
  </code></pre>