content: ion-alert, how to handle data or events from inputs is poorly documented

Open
#2,787 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
angular
Domain
documentation

Research direction

Start with the ion-alert API documentation and its linked example, reproducing the reported input and button-handler behavior. Update the documentation to clearly explain how to receive input data and handle input or alert events, then verify the example shows the expected value handling.

Written by the indexing model from the issue text.

Description

content
Describe the Bug

I try to handle alert input value but I cannot catch the handler ever

async presentAlert(isResidentOwner: boolean) {
    const alert = await this.alertController.create({
      buttons: [
        {
          text: 'Cancel',
          role: 'cancel',
          cssClass: 'danger',
          handler: () => {
            if (isResidentOwner) {
              this.ownerAmountPayment = false;
            } else {
              this.rentAmountPayment = false;
            }
          },
        },
        {
          text: 'Proceed',
          handler: (alertData) => {
            this.confirm(alertData.amount);
          },
        },
      ],
      inputs: [
        {
          id: 'modal_amount',
          name: 'modal_amount',
          placeholder: 'Amount',
          max: 15,
          handler: () => {
            console.log('Val Change'); // doesn't work
          }
        },
      ],
    });

    await alert.present();
  }
Expected Behavior

Throw console log

Steps to Reproduce

You can try code with https://ionicframework.com/docs/api/alert

Screenshots
Screenshot 2023-02-23 at 17 32 38
Operating System

MacOs

Browser

Chrome(Brave)

Version

Version 1.48.164 Chromium: 110.0.5481.100 (Official Build) (arm64)

Additional Information

Ionic:

Ionic CLI : 6.20.1
Ionic Framework : @ionic/angular 6.5.2
@angular-devkit/build-angular : 13.3.10
@angular-devkit/schematics : 13.2.6
@angular/cli : 13.2.6
@ionic/angular-toolkit : 6.1.0

Capacitor:

Capacitor CLI : 4.6.1
@capacitor/android : 4.6.1
@capacitor/core : 4.6.1

Utility:

cordova-res : 0.15.4
native-run : 1.6.0

System:

NodeJS : v18.14.2
npm : 9.5.1
OS : macOS

Dominant language
MDX
Stars
621
Forks
3.2k
Avg merge
1d 2h
Merged PRs (30d)
86

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ionic-team/ionic-docs

All issues in ionic-team/ionic-docs

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.