jait23 jait23 - 9 days ago 8
HTML Question

Reload data after modal gets closed in angularJS

-->html code

<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 code

$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
};
}
}
});
}


I want to reload the page after modal popup gets closed. How should I accomplish it?

Answer

I use 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;
    }
});

For $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'
}); 
Comments