简体   繁体   中英

after login when click hardware back button navigated to login page how to prevent it in ionic 4

const routes: Routes = [ { path: '', component: TabsPage, children: [ //new page add { path: 'home', children: [ { path: '', loadChildren: () => import('../AllPages/home/home.module').then(m => m.HomePageModule) }, { path: 'new-arrival', children: [ { path: '', loadChildren: () => import('../AllPages/new-arrival/new-arrival.module').then(m => m.NewArrivalPageModule) }, { path: 'product-item-list', children: [ { path: '', loadChildren: () => import('../Allpages/product-item-list/product-item-list.module').then(m => m.ProductItemListPageModule) }, { path: 'product-details', children: [ { path: '', loadChildren: () => import('../Allpages/product-details/product-details.module').then(m => m.ProductDetailsPageModule) }, ] } ] } ] },

Use Ionic NavController instead of Angular Router.
Then, use the navigateRoot method.

Going root means that all existing pages in the stack will be removed, and the navigated page will become the single page in the stack.

import { NavController } from '@ionic/angular';
...
constructor(private navController: NavController) {}
...
this.navController.navigateRoot('/tabs/home');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM