Close ion-select after open it programmatically


#1

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>


#2

I temporarily solved my problem with a setTimeout


#3

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

read this


#4

In my case I need this


#5

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.


#6

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…