Handling hardware back button in Ionic3 Vs Ionic4

前端 未结 6 1594
悲哀的现实
悲哀的现实 2020-12-01 09:30

Please find the below code for the Android hardware back button action in ionic3. As Ionic4 uses angular routing for navigation how the pop event w

6条回答
  •  心在旅途
    2020-12-01 09:59

    Customizing Android Back Button in Ionic 4 ... Each page wise back.

    Step 1: import { Platform, NavController } from '@ionic/angular';

    Step 2: constructor(public navCtrl: NavController){}

    Step 3:

     private async onBack() {
        this.navCtrl.navigateBack('/project-details');
      }
    

    Step 4:

     this.platform.backButton.subscribe(()=>{
            this.onBack();
          });
    

提交回复
热议问题