Monaca Onsen UI Discord Chat Github Repo

Onsen UI2 - handling the hardware back button



  • Can someone help me on, how to handle device back button.
    I am using Cordova+Angular5+OnsenUI2

    export class AppComponent implements OnInit {
      initialPage = FirstPageComponent;
      ngOnInit() {
        ons.ready((e) => {
          ons.disableDeviceBackButtonHandler();
          // ons.onDeviceBackButton();
        });
      }
    }
    
    

    Please help me how to handle backbutton, i would like execute a scenario where i have Page1, Page2, Page3.
    When i am in Page3 when device backbutton pressed it should go to Page 2, then same for Page2, Once it reached to Page1 on click on back it should popup for exit app? if yes terminate app.