当我点击Android后退按钮时,我的弹出窗口应该关闭。它没有关闭。弹出窗口不应该出现。我必须覆盖android后退按钮操作。
$ionicPopup.show({
templateUrl: 'templates/time-picker-12-hour.html',
title: '<strong>12-Hour Format</strong>',
subTitle: '',
scope: scope,
buttons: [{
text: 'Cancel'
}, {
text: 'Set',
type: 'button-assertive',
onTap: function (e) {
scope.loadingContent = true;
var totalSec = 0;
if (scope.time.hours != 12) {
totalSec = (scope.time.hours * 60 * 60) + (scope.time.minutes * 60);
} else {
totalSec = scope.time.minutes * 60;
}
if (scope.time.meridian === "AM") {
totalSec += 0;
} else if (scope.time.meridian === "PM") {
totalSec += 43200;
}
scope.etime = totalSec;
}
}]
})
答案 0 :(得分:3)
结帐this solution(但不要忘记取消注册您的事件处理程序 - 请参阅the docs for registerBackButtonAction
编辑:为了回答永久性,代码片段来处理android后退按钮:
$ionicPlatform.registerBackButtonAction(function () {
//close your ionic modal here
}, 100);