i'm creating a ionic 4 app, and i want to use the device's hardware back-button to return at specific page
i'd checked in this page Handling hardware back button in Ionic3 Vs Ionic4 to create my code but it doesn't work
detallesusuario.page.ts
import { Subscription } from 'rxjs';
import { Component, OnInit, AfterViewInit, QueryList, ViewChildren}from '@angular/core';
import { Platform, IonRouterOutlet } from '@ionic/angular';
import { Router } from '@angular/router';
@Component({
selector: 'app-detallesusuario',
templateUrl: './detallesusuario.page.html',
styleUrls: ['./detallesusuario.page.scss'],
})
export class DetallesusuarioPage implements OnInit, AfterViewInit {
@ViewChildren(IonRouterOutlet) routerOutlets: QueryList<IonRouterOutlet> ;
sub:Subscription
constructor(private platform:Platform, private ruta:Router) { }
ngAfterViewInit(): void {
this.backButtonEvent();
}
ngOnInit() {
}
ngOnDestroy() {
this.sub.unsubscribe();
}
backButtonEvent() {
let u=0;
this.sub=this.platform.backButton.subscribeWithPriority(0, () => {
this.routerOutlets.forEach(async(outlet: IonRouterOutlet) => {
console.log('paso');
await this.ruta.navigate(['menu/inicio/tabs/tab1']);
});
});
}
}
When i deploy a app to a device, the button return to the previous page instead to go at the specific page