2016-11-25 44 views
2

- > HTML代码刷新数据获取angularJS关闭

<button type="button" class="btn btn-primary" ng-click="platformAppConfigurationCreate()"> 
               <span class="fa fa-plus"></span> 
               <span class="hidden-xs hidden-sm"> 
                Create 
               </span> 
               </button> 

- > Controller.js代码

$scope.platformAppConfigurationCreate = function() { 
       $uibModal.open({ 
        templateUrl: 'app/entities/platform-app/platform-app-configuration-dialog.html', 
        controller: 'PlatformAppConfigurationDialogController', 
        controllerAs: 'vm', 
        backdrop: 'static', 
        size: 'lg', 
        resolve: { 
         entity: function() { 
          return { 
           appConfigUuId: null, 
           appConfigName: null, 
           appConfigDesc: null, 
           appConfigDisplayImageRef: null, 
           appConfigExtraInfo: null, 
           id: null 
          }; 
         } 
        } 
       }); 
     } 

我想模式弹出被关闭后重新加载页面。我应该如何实现它?

+0

有模态关闭时调用的函数。 – AlainIb

+0

你使用angular-ui吗? –

+0

http://stackoverflow.com/questions/36066602/is-there-a-way-to-intercept-bootstapuis-uibmodal-dismissed-event – AlainIb

回答

2

处理关闭事件,做你的代码中有

$scope.platformAppConfigurationCreate = function() { 
      $uibModal.open({ 
       templateUrl: 'app/entities/platform-app/platform-app-configuration-dialog.html', 
       controller: 'PlatformAppConfigurationDialogController', 
       controllerAs: 'vm', 
       backdrop: 'static', 
       size: 'lg', 
       resolve: { 
        entity: function() { 
         return { 
          appConfigUuId: null, 
          appConfigName: null, 
          appConfigDesc: null, 
          appConfigDisplayImageRef: null, 
          appConfigExtraInfo: null, 
          id: null 
         }; 
        } 
       } 
      }).closed.then(function(){ 

      //handle ur close event here 
      alert("modal closed") 

    } 
+0

非常感谢你 –

0

我用ngDialog

ngDialog.open({ 
    showClose: true, 
    template: 'partials/directives/bibliographie/popupAdd.html', 
    className: 'ngdialog-theme-default ngdialog-fullscreen', 
    scope: $scope, 
    closeByDocument: false, 
    closeByEscape: true, 
    controller: ['$scope', function ($scope) { 

    }], 
    preCloseCallback: function (value) { 
     // called when you close modal 
     if (value === 1) { 
      ; 
      return true; 
     } 

     return false; 
    } 
}); 

为$ uibModal:

var modalInstance = $uibModal.open({ 
    templateUrl: 'a-template.html', 
    controller: ['$scope', function($scope){ 
    $scope.$on('modal.closing', function(event, reason, closed){ 
     if('condition for not closing') 
      event.preventDefault(); //You can use this to prevent the modal from closing    
     else 
      window.location = "https://www.youtube.com/watch?v=dQw4w9WgXcQ";    
    } 
    }], 
    controllerAs: 'modal', 
    backdrop: false, 
    size: 'lg' 
}); 
0

您可以使用下面的脚本

$scope.$on('modal.closing', function(event, reason, closed){ 
    //either reload the state 
    $state.reload(); 
    //or redirect to a url 
    window.location.href="your url"; 

}