Property 'willLeave' does not exist on type 'Modal'

I am trying to use View Hooks on a modal, but I am facing an error: modal.willLeave.subscribe does not exist.

Here is the full code of the file:

import { IonicPage, ModalController, NavController, NavParams } from 'ionic-angular';

import { Component } from '@angular/core';
import { Quote } from '../../data/quote.interface';
import { QuotePage } from '../quote/quote';
import { QuotesProvider } from '../../providers/quotes/quotes';

@IonicPage()
@Component({
  selector: 'page-favorites',
  templateUrl: 'favorites.html',
})
export class FavoritesPage {
  quotes: Quote[];
  constructor(public navCtrl: NavController, public navParams: NavParams, public quotesService: QuotesProvider, public modalCtrl: ModalController) {
  }

  ionViewWillEnter() {
    this.quotes = this.quotesService.getFavoriteQuotes();
  }

  onViewQuote(quote: Quote) {
    const modal = this.modalCtrl.create(QuotePage, quote);
    modal.present();
    modal.onDidDismiss((remove: boolean) => {
      console.log(remove);
    });
    modal.willLeave.subscribe((remove: boolean) => {
      console.log(remove);
    });
  }

}

The other file I am passing the data from modal using View Controller:

import { IonicPage, NavController, NavParams, ViewController } from 'ionic-angular';

import { Component } from '@angular/core';

@IonicPage()
@Component({
  selector: 'page-quote',
  templateUrl: 'quote.html',
})
export class QuotePage {
  person: string;
  text: string;

  constructor(public navCtrl: NavController, public navParams: NavParams, public viewCtrl: ViewController) {
  }

  ionViewDidLoad() {
    this.person = this.navParams.get('person');
    this.text = this.navParams.get('text');
  }

  onClose(remove = false) {
    this.viewCtrl.dismiss(remove);
  }
}

What am I doing wrong?

I am having the same issue here. Please let me know if you have a solution for it.

No, I haven’t found a solution to this issue.

@amanhimself I see you are also following the Udemy course.
Simply replace willLeave with onDidDismiss and remove .subscribe.

Don’t mug up…u did nothing wrong…u don’t need to do that part…onDidDissmiss()is doing it already