Cannot use ion-nav.getByIndex() in ionic-angular

Cannot use ion-nav.getByIndex() in ionic-angular v4.

constructor(public navCtrl: NavController){}

getByIndex(){
    console.log( this.navCtrl.getByIndex() );
}

I get this message in the Console:


**ERROR in src/app/editevent/editevent.page.ts(316,42): error TS2339: Property 'getByIndex' does not exist on type 'NavController'.**

Can you actually use this in Angular? The docs are not clear at all.

To use ion-nav.getByIndex() , you need to use the ion-nav component (), but not the navController.

   const nav = document.querySelector('ion-nav') 
      	for(let i=0;i<100;i++) {    
           let v: any = await nav.getByIndex(i)     
           if (!v) // no more view
             break;
           console.log( v.component.name)
        }

Unfortunately, the method getLength() is not public yet which is why Iā€™m checking the validity of the first 100th views! : cf. pull request https://github.com/ionic-team/ionic/pull/17516

1 Like