Abhee
Abhee

Reputation: 73

ion-select popover interface is not getting hidden on hardware back button action

I used the popover interface on <ion-select> to display pop-over. In an Android device, if the user taps on ion-select but didn't select any option and click the hardware back button, it moves to the previous view but popover interface is still visible. Please help.

<ion-select interface="popover" [(ngModel)]="item.productType" placeholder="Please select" multiple="false" ionChange="onChange($event)" >
    <ion-option *ngFor="let opt of options" [value]="opt.value">{{opt.label}}</ion-option>
</ion-select>

Upvotes: 0

Views: 931

Answers (1)

Harry
Harry

Reputation: 235

Define page name in modal page.

pageName = "ModalPage";

Then register backbutton in app.component.ts

    this.platform.registerBackButtonAction(() => {
        let nav = this.app.getActiveNav();
        let view = nav.getActive().instance.pageName;

        if (view == 'ModalPage') {
            let activeView: ViewController =  nav.getActive();
            activeView.dismiss();
       } else {
          this.nav.pop();
      }
    }

Basically it will register your device backbutton to perform action when particular modal opened.

Feel free to comment for more help :)

Upvotes: 0

Related Questions