Remove page from navigation router / NavController. Ionic 4

Hi all ! Could anyone suggest please, if exist way to remove page from navigation router / NavController like in Ionic 3 ?

            this.nav.pop().then(() => {
                let views = this.nav.getViews();
                for (let i = 0; i < views.length; i++) {
                    if (views[i].getContent() == Page)
                        this.nav.removeView(views[i]);
                }
            });

Try this way,

let currentIndex = this.navController.getActive().index;
this.navController.push(DestinationPage).then(() => {
    this.navController.remove(currentIndex);
});

unfortunately property getActive() and remove not exist on type navController.

Can you please show me your navController declaration?

import {NavController} from “@ionic/angular”;

constructor(
public nav: NavController,
)

You have to use ‘ionic-angular’ instead of ‘@ionic/angular’
use below command for it.

npm i @ionic/angular

Then write below line for declaration

import {  NavController } from 'ionic-angular';

In Ionic 4, the package name is @ionic/angular.

While migrating from Ionic 3 to Ionic 4 I update the imports from ionic-angular to @ionic/angular.

But some of the property not working in this thta why i suggest you to do.

Ok. Thank you very much. I was thinking I can do it on Ionic 4.

All the actual routing in Ionic 4 is done by the Angular router, which doesn’t really have a concept of history. The way that <ion-router-outlet> implements its stack is private, and doesn’t really look like something that I would want to rely on diving into (it is merging multiple navigation stacks into a single stack controller).

So I think if you’re absolutely dead-set on trying to do this, what I would do is completely take over the back button and manage the navigation stack myself.