How to use ngModel with Prompt Alerts?

Hi,

I’m trying to use ngModel with Prompt Alerts. Is it possible ?
Where can I insert my [(ngModel)]=“password”

in the following code :
Prompt Alerts :

alertEncryptMemo(){
    let alert = this.alertCtrl.create({
      title: 'Encrypt this memo',
      message: 'Write the password then check again',
      inputs: [
        {
          name: 'password',
          placeholder: 'Password',
          type: 'password'
        },
        {
          name: 'password',
          placeholder: 'Password verification',
          type: 'password'
        }
      ],
      buttons: [
        {
          text: 'Set',
          role: 'set',
          handler: data => {
            console.log('Password Set');
          }
        },
        {
          text: 'Cancel',
          role: 'cancel',
          handler: data => {
            console.log('Cancelled');
          }
        },
      ]
    });
    alert.present();
    console.log("Encrypt Current Memo");
  }

Function if needed :

public safeMemo() {

    if (this.memoInfo.pwd != undefined) {
      alert("pwd != undefined");
    } 
    else
    {
      alert("pwd = undefined")
      bcrypt.genSalt(10, function(err, salt) {
        bcrypt.hash("B4c0/\/", salt, function(err, hash) {
        // Store hash in the password DB. 
        });
      });
    }
  }

This is still in development.

Thanks for your time & help ! :slight_smile:

@Petalomine I don’t think you can do it with alerts. The alert's functionalities are very limited. You can try it with a modal, passing a custom component (that can have ngModel in it) to the modal.

The modal docs: https://ionicframework.com/docs/api/components/modal/ModalController/

Although it seems that for now the modal occupy the entire screen and is a bit difficulty to style it to occupy just a part of the screen.

There’s a discussion about it here: