title: How to close Angular UI Modal from anywhere
body: <p>I am using the <a href="http://angular-ui.github.io/bootstrap/#/modal">Angular UI bootstrap modal dialog</a> and create it within a service:</p>
  
  <pre><code>myApp.factory('ModalService', ['$modal', function($modal) {
      return {
          trigger: function(template) {
              $modal.open({
                  templateUrl: template,
                  size: 'lg',
                  controller: function($scope, $modalInstance) {
                      $scope.ok = function() {
                          $modalInstance.close($scope.selected.item);
                      };
                      $scope.cancel = function() {
                          $modalInstance.dismiss('cancel');
                      };
                  }
              });
          },
          close: function() {
              // this should close all modal instances
          }
      };
  }]);
  </code></pre>
  
  <p>How can I close all modal instances when calling <code>ModalService.close()</code> from a controller or whatsoever?</p>