Android IONAL-订阅后退按钮关闭内部div
我有一个“搜索过滤器”div,它由Android IONAL-订阅后退按钮关闭内部div,android,angular,ionic-framework,Android,Angular,Ionic Framework,我有一个“搜索过滤器”div,它由this.show\u Filters==true条件显示 现在,我尝试使用android后退按钮将此变量设置为false async toggleFiltersWindow(){ console.log('#1 toggleFilters()'); this.show_filters = !this.show_filters; // registrar evento do botao hardware BACK const event = f
this.show\u Filters==true
条件显示
现在,我尝试使用android后退按钮将此变量设置为false
async toggleFiltersWindow(){
console.log('#1 toggleFilters()');
this.show_filters = !this.show_filters;
// registrar evento do botao hardware BACK
const event = fromEvent(document, 'backbutton');
let self = this;
if(this.show_filters == true){
console.log('#2 BACK BT - subscribe');
self.backbuttonSubscription = event.subscribe(async () => {
console.log('#3 BACK BT - clicked');
self.toggleFiltersWindow();
});
}else{
self.backbuttonSubscription.unsubscribe();
console.log('#4 BACK BT - unsubscribe');
}
}
这段代码显示了#1和#2个控制台日志,但当我单击“后退”按钮时,什么都没有发生
我做错什么了吗?那么,你的意思是它没有检测到硬件后退按钮吗?没错,@MridulIn顺序是检测硬件按钮,platform.backbutton.subscribowithpriority(99999,()=>{做点什么…@anderlaini,检查一下backbutton我发布了一个例子。那么,你的意思是它没有检测到硬件后退按钮?没错,@MridulIn为了检测硬件按钮,platform.backbutton.subscribewithpriority(99999,()=>{做点什么…@anderlaini,检查一下backbutton我发布了一个例子。
backButtonEvent() {
this.platform.backButton.subscribeWithPriority(999999, () => {
// navigator['app'].exitApp();
// or trigger any action you want to achieve
}
}