Messi007
Messi007

Reputation: 11

Ionic 2 navigate to the root page

How can I navigate to the root page with ionic 2, when i use this code :

 this.navCtrl.push('HomePage');

it made the error below

Uncaught (in promise): invalid link: HomePage

Capture of the error

Upvotes: 0

Views: 599

Answers (2)

Jakegarbo
Jakegarbo

Reputation: 1301

First Check your page component if you have

import { IonicPage } from 'ionic-angular';

and because your using lazy page loading you should have this. @ionicpage

@IonicPage()
@Component({
  ....
})

last resort is try to resart or reset your ionic serve. sometimes it happen . and i think its ionic bug. but no big deal.

Upvotes: 0

Gabriel Barreto
Gabriel Barreto

Reputation: 6421

You can use this.navCtrl.popToRoot();, It'll pop all views and there's no need to set a new root. This'll also not fire some lifecycle hooks like ionViewDidLoad() and ionViewWillLoad().

Hope this helps.

Upvotes: 0

Related Questions