0

How to get back to root application in IONIC 3.

main.js:1436 ERROR Error: Uncaught (in promise): invalid link: TabsPage(…)

import { Component, ViewChild, ElementRef } from '@angular/core'; 
import { NavController } from 'ionic-angular'; 
import { Geolocation } from '@ionic-native/geolocation'



@Component({   selector: 'page-registrar',  
               templateUrl: 'registrar.html' 
}) 

 export class RegistrarPage {    
   constructor(public navCtrl: NavController) {}

   ionViewDidLoad(){}


  openHomePage(){
    this.navCtrl.setRoot('TabsPage');   
  }

}
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
marcelo.delta
  • 2,730
  • 5
  • 36
  • 71
  • It's possible you've got a typo with the name of the page 'TabsPage'. But if you are not lazy loading page with @ IonicPage, then you have to use class name itself and import it - not a string in set root. I say that because your Registrar page doesn't have an @ IonicPage... See my note here. It may help https://stackoverflow.com/a/45721208/495157 – JGFMK Aug 20 '17 at 12:51

1 Answers1

0

Try this this.navCtrl.popToRoot()

From Ionic Doc. This will navigate back to the root of the stack, no matter how far back that is. Detail Link

Khurram
  • 695
  • 6
  • 16
  • I'm using tabs. With this.navCtrl.popToRoot () I get back to the root page, however I need to reload the root page with the first default tab. How is it possible? Thank you very much for your attention. – marcelo.delta May 20 '17 at 13:33
  • then using your setRoot method. make sure your are importing tabsPage in this component. and pass reference of that page. – Khurram May 20 '17 at 15:06
  • are you using lazy load? provide some more detail like tabs page and current page's component and template – Khurram May 20 '17 at 15:17
  • I tried using the setRoot with the tab name, but it does not work. – marcelo.delta May 21 '17 at 05:06