简体   繁体   中英

Method call while closing a bootstrap modal popup

I am trying to redirect to a page while closing a modal popup. But that's not happening.

I am trying to redirect to a page either by using

state.go() or by location.path() .

Here is the confirmation pop - up code in angular :

function modalMessage($rootScope,result) {
    $rootScope.FinalMessage = result.finalMessage;
    $rootScope.ReasonOrTransKey = result.ReasonOrTransKey;
    $rootScope.ConfirmationMessage = result.ConfirmationMessage;

    //Finds element with attribute iConfirmationModal
    angular.element("#iConfirmationModal").modal();
}

When the user clicks on the close() button I want put my redirect code.

在此处输入图片说明

since the jqLite does not support modal method, you should use $ instead of angular.element

Plunker

function modalMessage($rootScope,result) {
     $rootScope.FinalMessage = result.finalMessage;
     $rootScope.ReasonOrTransKey = result.ReasonOrTransKey;
     $rootScope.ConfirmationMessage = result.ConfirmationMessage;

     //Finds element with attribute iConfirmationModal
     $("#iConfirmationModal").modal();
     $("#iConfirmationModal").on('hidden', function(){
        $timeout(function(){
            $state.go(...)
        })
     })
}

This event is fired when the modal has finished being hidden from the user (will wait for css transitions to complete).

angular.element("#iConfirmationModal").on('hidden', function () {
  // do something…
})

http://getbootstrap.com/2.3.2/javascript.html#modals

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM