在我的代码中,当我触发 ionicPopup 时,点击按钮后,它会触发另一个 ionicPopup,但它应该关闭前一个 ionicPopup。但是,在我的实现中,虽然它关闭了最终的 ionicPopup,但最初的 ionicPopup 并没有关闭,而是隐藏了,这导致应用程序冻结。有没有办法确保所有 ionicPopup 都已关闭,或者至少在按钮点击时关闭每个 ionicpopup。这是我的代码http://codepen.io/anon/pen/dYVdJv的代码笔
$scope.showPopup = function() {
$scope.data = {}
$ionicPopup.show({
title: ' Session Terminated!',
scope: $scope,
template:' You are currently logged into another device/browser. Pls log out from your other device/browser!',
buttons: [
{ text: '<h6 style="text-transform: capitalize;">Cancel</h6>',
type: 'button-positive'
},
{
text: '<h6 style="text-transform: capitalize;">Verify Me</h6>',
type: 'button-positive',
onTap: function(e) {
$scope.verifyMe();
}
}
]
}).then(function(res) {
console.log('Tapped!', res);
}, function(err) {
console.log('Err:', err);
}, function(popup) {
console.log('Got popup', popup);
$timeout(function() {
popup.close();
}, 1000);
});
};
$scope.verifyMe = function() {
$ionicPopup.show({
title: ' Enter Username',
scope: $scope,
template:'<input type="text" ng-model="user.username">',
buttons: [
{
text: '<h5 style="text-transform: capitalize;">Verify Me</h5>',
type: 'button-positive',
onTap: function(e) {
$scope.verifyNow('first.app');
}
}
]
}).then(function(res) {
console.log('Tapped!', res);
}, function(err) {
console.log('Err:', err);
}, function(popup) {
console.log('Got popup', popup);
$timeout(function() {
popup.close();
}, 1000);
});
};
$scope.verifyNow = function(username) {
console.log("verified and removed" + username)
}
一旦代码执行完成,当我检查我的代码时我会得到这个
<div class="popup-container popup-showing popup-hidden" ng-class="cssClass">
//more code here
</div>
这实际上是在第一个 ionicPopup.show({}) 中打开的弹出窗口,第二个 ionicPopup.show({}) 被关闭。不知道为什么第一个只是隐藏而不是关闭。