title: Closing $uibModal On Exiting the $state
body: <p>I am using ui-router for routing in my angularjs app and ui-bootstrap for UI.In my app on entering a state i am opening a uibmodal which basically returns a uibmodalinstance but when i change a state using </p>
  
  <pre><code>$state.go('dashboard')
  </code></pre>
  
  <p>Inside my controller it is changing the state but didn't closing modal.
  So i want modal to be closed on exiting the state.
  i Have written following code but some part of code doesn't work.
  please see coding and the comments for  not working part</p>
  
  <pre><code>    $stateProvider.state('makeabid',{
                  parent: 'dashboard',
                  url: '/makeabid/{id}',
                  data: {
                      authorities: ['ROLE_USER'],
                      pageTitle: 'global.menu.makeabid'
                  },
                  onEnter: ['$stateParams', '$state', '$uibModal', function($stateParams, $state, $uibModal) {
                      $uibModal.open({
                          templateUrl: 'app/dashboard/makeabid/makeabid.html',
                          controller: 'MakeabidController',
                          controllerAs: 'vm',
                          backdrop: true,
                          size: 'lg'
                      }).result.then(function () {
                          $state.go('dashboard');
                      });
                  }]
  //this part doesnt work             
  ,onExit:['$uibModalInstance','$stateParams', '$state',function ($uibModalInstance,$stateParams, $state) {
                      $uibModalInstance.close();
                  }]
              });
  </code></pre>
  
  <p>My Controller Coding is as follows : -</p>
  
  <pre><code>MakeabidController.$inject = ['$stateParams','$state','$uibModalInstance','MakeabidService'];
  
      function MakeabidController( $stateParams, $state, $uibModalInstance, MakeabidService) {
          var vm = this;
          loadAll();
          vm.clear = clear;
          vm.save = save;
  
          function clear () {
              $uibModalInstance.close();
          }
  
          function save() {
              // console.log(vm.comparableData);
          }
  
          function loadAll() {
              vm.comparableData = MakeabidService.getobject();
              if(angular.isUndefined(vm.comparableData)){
  //$uibModalInstance.close(); //It doesn't work
                      $state.go('dashboard'); //This is working 
                  }
              }
          }
  </code></pre>
  
  <p>AnyOne Please Tell me solution for closing the uibmodal on changing state</p>