Is there a way to manually delete a page and then navigate to it and reinitialize it again?

For example, a page that hosts a video player, which could lead to other video player pages - e.g. when user taps anything under “suggested videos”. It’s desirable to always destroy the previous page due to its resource intensiveness and reinitialize instead of pushing multiple pages into the nav stack.

Is there a way in ionic 2 or angular 2?

have you seen this:

and this:

1 Like

Here is what I tried:

  ionViewDidLeave() {
    const prevView = this.nav.getPrevious(this.viewController);
    if (prevView && prevView.name === 'DetailPage') {
      this.nav.remove(this.viewController.index);
    }
  }

Basically what I was trying to do is to detect if previous page is the same “DetailPage”, if so remove it from the stack, but after I went to “DetailPage” a few times and clicked the back button, it still took me to previous DetailPage. What am I doing wrong?

Thanks.

Figured it out

export class DetailPage {

  showItem(itemID) {

      this.nav.remove(this.nav.last().index)
        .then(
          () => {
            this.nav.push(DetailPage, {
              itemID
            });
          },
          error => {}
        );

  }

}
4 Likes