Ionic-select checked on ion-option doesn't work and also selectOptions do not work

We use ionic-select and could not get work checked and selectOptions

This is my example code:

<ion-select [(ngModel)]="sensorId" [selectOptions]="sensorSelectOptions" name="sensorId">
            <ion-option value="abc" checked="true">abc</ion-option>
            <ion-option value="def">def</ion-option>

  private sensorSelectOptions = {
     buttons: [{
        text: 'BlaBla',
          handler: () => {
              console.log('clicked me');

First mistake: The first ion-option is not pre selected
Second mistake: there is now way to add custom buttons to the dialog

I think this should be a bug, but the Ionic Team closed my bug on github and told me to open a support question on the forum

some help or ideas?

Instead of trying to set checked to true, set the value of sensorId in the component to “abc”.

okay so the documentation is wrong??

And what about the second mistake? As described in documenation selecOptions should be set custom buttons as in the AllertController API interface


Doesn’t look that way to me.

    // make sure their buttons array is removed from the options
    // and we create a new array for the alert's two buttons
    selectOptions.buttons = [{
      text: this.cancelText,
      role: 'cancel',
      handler: () => {

Starting at line 264 of the select component.

I did it in thiis way, what should be the same thing.

private sensorSelectOptions = {
     title: 'BlaBla'
     buttons: [{ ..... })

title works, buttons doesn’t

Of course. I posted the exact bit of the source that overrides the buttons.

okay, thx
I’m out of office, I’ll try it tomorrow morning!

Hi @rapropos I tested anything

  1. it was the wrong property, it is not checked but selected. I don’t know if I read the wrong thing or if the documentation changed yesterday? Nevertheless using selected works

  2. As I can see from the link for the source code you send me. The custom buttons set are ALWAYS overwritten from the open() function. So we can not set custom buttons, but reading the documentation we should?
    Reading AlertController API docs we can set also buttons, but this would be overwritten from open function.

1 Like

Thanks for reporting back. I guess the documentation is a bit ambiguous.