使用 angular 在 ionic 打字稿中获取警报控制器中的输入值

Getting values of inputs in alert-controller in typescript of ionic with angular

我正在使用 Ionic (angular) 框架,我想从输入的 alert-controller 中获取值这里要在函数中使用它们,有什么办法吗?

async presentAlertPrompt(resp) {
const alert = await this.alertController.create({
      cssClass: 'my-custom-class',
      header: 'Update!',
      inputs: [
        {
          type: 'text',
          value: resp.food_name,
        },
        {
          type: 'text',
          value: resp.food_price
        },
        // multiline input.
        {
          type: 'textarea',
          value: resp.food_description
        }
      ],
      buttons: [
        {
          text: 'Cancel',
          role: 'cancel',
          cssClass: 'secondary',
          handler: () => {
            console.log('Confirm Cancel');
          }
        }, {
          text: 'Ok',
          handler: () => {
            console.log('Confirm Ok');
            })
          }
        }
      ]
    });

    await alert.present();
}
async presentAlertPrompt(resp) {
const alert = await this.alertController.create({
      cssClass: 'my-custom-class',
      header: 'Update!',
      inputs: [
        {
          type: 'text',
          name: 'foodName',
          value: resp.food_name,
        },
        {
          type: 'text',
          name: 'foodPrice',
          value: resp.food_price
        },
        // multiline input.
        {
          type: 'textarea',
          name: 'foodDescription',
          value: resp.food_description
        }
      ],
      buttons: [
        {
          text: 'Cancel',
          role: 'cancel',
          cssClass: 'secondary',
          handler: () => {
            console.log('Confirm Cancel');
          }
        }, {
          text: 'Ok',
          handler: (values) => {
            console.log(values.foodName);
            console.log(values.foodPrice);
            console.log(values.foodDescription);
            
            console.log('Confirm Ok');
            })
          }
        }
      ]
    });

    await alert.present();
}