Ordering multiple IonicModals on top of each other

前端 未结 4 1928
醉话见心
醉话见心 2021-01-18 21:56

The usage of the $ionicModal service is explained here: http://ionicframework.com/docs/api/service/$ionicModal/

I have a situation where it happens that I open more

4条回答
  •  自闭症患者
    2021-01-18 22:23

    Another solution would be to append and remove the modal from the DOM each time the modal is opened and closed respectively. This way the modal will always be the last one appended to the DOM when it is opened.

    Here is the code I've been using:

         // Open the login loginModal
        $scope.openLoginModal = function() {
            $ionicModal.fromTemplateUrl('templates/login.html', {
                scope: $scope
            }).then(function(loginModal) {
                $scope.loginModal = loginModal;
    
                // Show modal once it's finished loading
                $scope.loginModal.show();
            });
        };
    
        // Close login modal
        $scope.closeLogin = function() {
            $scope.loginModal.hide();
    
            // Remove login modal from the DOM
            $scope.loginModal.remove();
        };
    

提交回复
热议问题