简体   繁体   中英

How to close ionic popup from app.js run function?

After login, users have to accept a disclaimer text on the home page before they proceed any further, i'm displaying this in a ionic popup alert as shown below. The issue is if the user doesn't click OK on the popup and the page times out, the user is redirected to the login page but the popup still remains open on the login page which is a usability issue, therefore I am trying to force close/dismiss the popup from app.js run function just before they are redirect to the login page.

I'm not sure how to call or identify the popup variable or showDisclaimer function declared on the home page from app.js run function and close it?

home.js

showDisclaimer: function() {
            var popUp = $ionicPopup.alert({
              title: 'Disclaimer',
              cssClass: 'disclaimer-popup',
              template: '..By Clicking the OK button I agree to the terms',
              okType: 'button-calm'
            });

            popUp.then(function(res) {
                popUp.close();
            });
        }

Something along the lines of

On app.js page

$rootscope.home.showDisclaimer.popUp.close();

How can I close the ionicpopup from the run function on app.js page?

Any help will be greatly appreciated. Thanks in advance.

$scope.$on("$destroy", function(){
     popUp && popUp.close();
});

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