ionViewCanLeave conditional AlertController not working?


#1
async ionViewCanLeave() {
    const leaving = await this.canLeave();
    return leaving;
  }

  canLeave() {
    let resolveLeaving;
    const canLeave = new Promise<boolean>(resolve => resolveLeaving = resolve);
    const alert = this.alertCtrl.create({
      title: 'Confirm leave', /* | translate */
      message: 'Do you want to leave the page?', /* | translate */
      buttons: [
        {
          text: 'No', /* | translate */
          role: 'cancel',
          handler: () => resolveLeaving(false)
        },
        {
          text: 'Yes', /* | translate */
          handler: () => resolveLeaving(true)
        }
      ]
    });
    if (this._profile && this._profile.dsCustData && this._profile.dsCustData.ttContact) {
      if (this._profile.dsCustData.ttContact.length > 0 && this._profile.dsCustData.ttContact.any(x => x.Name === '' || x.MailAddress === '')) {
        alert.present();
        return canLeave;
      }
    }
    resolveLeaving(true);
    return canLeave;
  }

This is my code for ionViewCanLeave however nothing happens.
If I place the condition in comments the code words, promise resolves true.

if (this._profile && this._profile.dsCustData && this._profile.dsCustData.ttContact) {
      if (this._profile.dsCustData.ttContact.length > 0 && this._profile.dsCustData.ttContact.any(x => x.Name === '' || x.MailAddress === '')) {
        alert.present();
        return canLeave;
      }
    }

I can also use resolveLeaving(false) or just call the alert.peresent(); but the moment I uncomment the condition nothing will happen anymore.