alertController inputs disable not working

Team,

I am trying to use an alert for data input confirmation before submission and would like to disable the input field so that it is read only. The alertController actually has a disable property that accepts a boolean but it does not seem to be working correctly. Is the disable property used for a different purpose than what I understand it to be? Or maybe I should be using a different component but I find the alert pretty straightforward for this purpose. Below is my alert method, what am I missing?

cardPrompt() {
    let prompt = this.alertController.create({
      title: this.translate.instant("creditcard.content.alerts.confirmation"),
      inputs: [
        {
          name: "amount",
          value: this.creditcardForm.controls["amount"].value,
          disabled: true
        },
        {
          name: "fullName",
          value: this.creditcardForm.controls["fullName"].value,
          disabled: true
        },
        {
          name: "cardNumber",
          value: this.creditcardForm.controls["cardNumber"].value,
          disabled: true
        },
        {
          name: "cardType",
          value: this.creditcardForm.controls["cardType"].value,
          disabled: true
        },
        {
          name: "expiration",
          value: this.creditcardForm.controls["expiration"].value,
          disabled: true,
        },
        {
          name: "cvv",
          value: this.creditcardForm.controls["cvv"].value,
          disabled: true
        }
      ],

      buttons: [
        {
          text: 'Cancel',
          role: 'cancel',
          handler: data => {
            console.log('Cancel clicked');
          }
        },
        {
          text: 'Confirm',
          handler: data => {
            console.log('Saved clicked');
          }
        }
      ]
    });
    prompt.present();
  }

I might be late but this worked for me.
var bool=true;

and then in addInput
disable:bool

I am not sure why I had to do it this way, but it works.

1 Like