Close ion-select after open it programmatically

I use @ViewChild to open programmatically a Select box and once is open, I can’t close it with the conventional buttons (Done or Cancel). Somebody have a solution to close the select-popup.

This problem only occur when i’m trigger the other select box from a other select, like:
<ion-select [(ngModel)]="test" (ionChange)="openSecondSelect($event)"></ion-select>

I temporarily solved my problem with a setTimeout

You usually don’t have to programm the open and close function unless you want to add a special function to it.

read this

In my case I need this

Try:

this.yourselectbox.close();

or:

this.yourselectbox.dismiss();

or one of those

this.viewCtrl.dismiss();

this.viewCtrl.close();

I never putted a function into the ion-select i only used the “dismiss” function on a modal controller.

My problem is the conventional button in the select box doesn’t work and only occur when I open a select box at the end of a other.

<ion-select [(ngModel)]="test" (ionChange)="openSecondSelect($event)"></ion-select>

<ion-select #secondSelect></ion-select>

openSecondSelect($event) {
    /* secondSelect come from ViewChild variable*/
    this.secondSelect.open();
}

May be is a bug or something i miss understand. But if I put a setTimeout in my function for opening the second select box, everything is OK…

1 Like