1

good morning. Does anyone know the import of the NavController? I am looking at the docs of Ionic 4 docs and it says there is a method of getPrevious() however when I do:

import { NavController } from ‘@Ionic/angular’;

contructor (private navCtrl: NavController){}

private func(): void{
  this.navCtrl.getPrevious();
}

I get an error saying property getPrevious does not exist on type NavController however in the docs it says that it exists. anyone aware of the proper import since it isn't documented?

previously you were able to do this with Ionic 2-3 but not Ionic 4.

side note* method last() doesn't exist either.

Ctfrancia
  • 1,248
  • 1
  • 15
  • 39
  • 1
    This helped me with a similar issue in ionic4: https://stackoverflow.com/a/62851249/1188605 – Js. Jul 07 '21 at 18:18

1 Answers1

0

What do you want to do? If you want to go back, than you could use the ion-back-button.

  <ion-buttons slot="start">
      <ion-back-button color="light"></ion-back-button>
  </ion-buttons> 

Also you can use the NavController like this to get forward:

  constructor(private navCtrl: NavController) { }

  GotoImpressum() {
    this.navCtrl.navigateForward('impressum');
  }
raffaval
  • 31
  • 8