title: Using $uibModalInstance in directive
body: <p>When opening a bootstrap ui modal, if you prefer to use a directive, rather than separately a <code>templateUrl</code> and <code>controller</code>, how can you then in the controller of the directive for the modal, access <code>$uibModalInstance</code> in order to close the modal or whatever you need to do? Also, how can we pass <code>items</code> without having to add it as an attribute on the template?</p>
  
  <pre><code>angular.module('myModule', ['ui.bootstrap'])
  .directive('myDirective', ['$timeout', function ($timeout) {
  
      var controllerFn = ['$scope', '$uibModal', function ($scope, $uibModal) {
  
              $scope.names = ['Mario','Wario','Luigi'];
  
              $scope.openModal = function () {
                  var modalInstance = $uibModal.open({
                      animation: true,
                      template: '&lt;my-modal&gt;',
                      size: 'lg',
                      resolve: {
                          items: function () {
                              return $scope.names;
                          }
                      }
                  });
              };
          }];
  
      return {
          restrict: 'E',
          templateUrl: '/Folder/my-directive.html',
          controller: controllerFn,
          scope: {
          }
      };
  }])
  .directive('myModal', ['$timeout', function ($timeout) {
  
      var controllerFn = ['$scope', function ($scope) {
      }];
  
      return {
          restrict: 'E',
          templateUrl: '/Folder/my-modal.html',
          controller: controllerFn,
          scope: {
          }
      };
  }]);
  </code></pre>