How to redirect to ionic 2 page without push / popping

I am building an application with Ionic 2. After a successful login, the home page will be clicked on top of the login page. The only problem is that the back icon is displayed at the top of the home page. I want to be redirected to the main page when I log in so that the back icon does not appear.

thank

+4
source share
2 answers

You have to setRoot. So the new component is the root, which in your case will be the HomePage component.

this.navCtrl.setRoot(HomePageComponent, {}, {animate: true, direction: 'forward'});
+8
source

, this.navCtrl.setRoot(YourDesiredPageClassHere) NavigationController this.navCtrl.push(YourDesiredPageClass). DesiredPageClass, - , , , , .

"", showBackButton(false) ViewController , :

import { NavController, ViewController } from 'ionic-angular';

export class Page {

    constructor(
        private navCtrl: NavController, 
        private viewCtrl: ViewController
    ) { }

    ionViewWillEnter() {
        this.viewCtrl.showBackButton(false);
    }
}

"" HTML hideBackButton ( hide-back-button) :

<ion-navbar hideBackButton="true">
    <ion-title>Title</ion-title>
</ion-navbar>
+2

Source: https://habr.com/ru/post/1671154/


All Articles