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

Get calling component inside handler for pickerOptions

$
0
0

Hey, I was wondering if there is a way to get the calling component inside the handler for a PickerButton in my customPickerOptions.

The problem is, I have a form that has multiple ion-datetime components, and I would like to avoid having to define customPickerOptions for every single one of them separately.

Currently, I have it like this:

pickerOptionsFusionGeplant = {
    buttons: [
      {
        text: "ok",
        role: "ok",
        handler: (e) => {
          this.object.value1 = GeneralService.getUTCStringFromPickerData(e);
        }
      },
      {
        text: "cancel",
        role: "cancel"
      },
      {
        text: "clear",
        handler: (e) => {
          this.object.value1= '';
        }
      }]
  };

and I would like it to be something more like this:

  pickerOptionsFusionGeplant = {
    buttons: [
      {
        text: "ok"
        role: "ok",
        handler: (e,v) => {
          //v could be ID, or better yet the name of my formControl
          
          this.object[v] = GeneralService.getUTCStringFromPickerData(e);
        }
      },
      {
        text: "cancel",
        role: "cancel"
      },
      {
        text: "clear",
        handler: (e,v) => {
          this.object[v] = '';
        }
      }]
  };

I’ve read a bunch about using pickerOptions, and I have a few questions regarding that in general:

  • Is it normal that my pickerOptions override the default buttons? I had to re-define them (including handlers) to get them to work. I’ve read on git that it should be enough to define a role (like ‘ok’ or ‘done’) but the button still doesn’t work when I do only that.
  • Wasn’t a “clear” button-role supposed to be already introduced and merged? See here - Am I just doing something wrong?

Thanks for any pointers, this isn’t a fun topic to research on google.

Cheers.

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48984

Trending Articles



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