title: How to close Angular-ui modal from other controller
body: <p>I am using Angular-ui to pop up a modal with a form in it. My code is:</p>
  
  <pre><code>app.controller('NewCaseModalCtrl', ['$http', '$scope','$modal', function ($http, $scope, $modal, $log) {
  
    $scope.items = ['item1', 'item2', 'item3'];
    $scope.open = function (size) {
  
      var modalInstance = $modal.open({
        templateUrl: 'modal-new-case.html',
        controller: 'ModalInstanceCtrl',
        size: size,
        resolve: {
          items: function () {
            return $scope.items;
          }
        }
      });
  
      modalInstance.result.then(function (selectedItem) {
        $scope.selected = selectedItem;
      }, function () {
      });
    };
  }]);
  </code></pre>
  
  <p>And then I have another controller that is inside the modal-new-case.html template, and I want it to run an httpd request and then close that modal, here is that code:</p>
  
  <pre><code>    app.controller('CreateCaseFormCtrl', ['$http','$scope', function($http,$scope) {
      $scope.formData = {};
      $scope.processForm = function() {
  
          $http.post('http://api.com/proj', $scope.formData).
          success(function(data, status, headers, config) {
              console.log("success " + data.id);
          }).
          error(function(data, status, headers, config) {
              console.log("Error " + status + data);
          });
      };
  </code></pre>
  
  <p>}]);</p>
  
  <p>Okay so inside my modal-new-case.html template, which is loaded when I do:</p>
  
  <pre><code>ng-controller="NewCaseModalCtrl"
  </code></pre>
  
  <p>I have this HTML:</p>
  
  <pre><code>&lt;div ng-controller="CreateCaseFormCtrl"&gt;
      &lt;form ng-submit="processForm()"&gt;
                  &lt;button class="btn btn-primary" ng-click="processForm()" &gt;OK&lt;/button&gt;
                  &lt;button class="btn" ng-click="cancel()"&gt;Cancel&lt;/button&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>So if you see, what I really want to do is to run that processForm() function, and when it returns with a success, I want to THEN call the function that will close the modal, which I believe "cancel()" would be fine.</p>
  
  <p>But I don't know how to refer to it from the CreateCaseFormCtrl controller.</p>
  
  <p>I appreciate any thoughts and help, and I would like to add that I am very unsophisticated when it comes to Angular, so if this is complicated, please remember that maybe I am not 100% clear on what every single thing in Angular is such as the factories and such. I guess I'm saying I'm very happy with a dirty solution that's fairly simple, since this isn't going to be long-term production programming code.</p>