在我的代码,当我触发ionicPopup,在按钮点击,它会触发另一ionicPopup但它应该关闭以前ionicPopup。然而,在我的实现,同时它关闭最后ionicPopup,初始ionicPopup犯规接近,而它隐藏这将导致应用程序冻结。有没有办法确保所有ionicPopups都是关闭的,或者至少它们会在按钮点击时关闭每个ionicpopup。这是我的代码codepen http://codepen.io/anon/pen/dYVdJvionicPopup不关闭只隐藏。
$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({})被关闭。不知道为什么第一个只隐藏而不是关闭。
$超时的代码在这里最重要的一块。感谢分享。 –