Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48977

Ionic 5 ion-alert: ngModel is not working when used inside message string

$
0
0

Hi,

The quantity value is not getting bind in ngModel. can anyone tell how to bind quantity field and get user entered value on dismiss of alert?.
thanks in advance :grinning:

image

async presentAlertPrompt() {

this.quantity = 0;

const alert = await this.alertController.create({

  cssClass: 'my-custom-class',

  header: 'Prompt!',

  mode: 'ios',

  message: new IonicSafeString(`<ion-list><ion-item><ion-label position="stacked"><span>${this.cs.GlobalValue.quantity}</span></ion-label>

  <ion-input type="number" placeholder="enter quantity" min=0 [(ngModel)]="quantity"></ion-input></ion-item></ion-list>`),

  buttons: [

    {

      text: 'Cancel',

      role: 'cancel',

      cssClass: 'secondary',

      handler: () => {

        console.log('Confirm Cancel');

      }

    }, {

      text: 'Ok',

      handler: (event) => {

        console.log(this.quantity);

      }

    }

  ]

});

await alert.present();

alert.onDidDismiss().then(res => {

  console.log(this.quantity)

})

}

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48977

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>