Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android IONAL-订阅后退按钮关闭内部div_Android_Angular_Ionic Framework - Fatal编程技术网

Android IONAL-订阅后退按钮关闭内部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

我有一个“搜索过滤器”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 = 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
    }

}