关闭ionic2 datetime弹出窗口,同时按下返回按钮? [英] closing ionic2 datetime popup, while pressing back button?

查看:50
本文介绍了关闭ionic2 datetime弹出窗口,同时按下返回按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ionic2 ion-datetime,当我返回到我的应用程序时,尽管在后页中没有离子数据时间标签,但仍然显示日期选择器弹出窗口.帮我删除按下后退按钮上的弹出声

I am using ionic2 ion-datetime, when I am going back in my application, still, date picker popup is showing, although there is no ion-data time tag in back page. help me to remove this pop on pressing back button

.html文件

<ion-datetime id="dateofbirth" class="date" displayFormat="DD MMMM YYYY" [max]="maxDate" [min]="minDate">

.ts文件(这里我已经写了一些自定义日期时间的逻辑)

.ts file(here i have written some logic for custom date time)

let date: any = new Date(),
        maxYear = date.getFullYear() - 18, minYear = date.getFullYear() -65,
        month = date.getMonth() + 1, minDay:any = date.getDate(),
        this.minDate = minYear + "-" + month + "-" + minDay;
        this.maxDate = maxYear + "-" + month + "-" + maxDay;

推荐答案

在您的.ts文件中使用以下代码,在该文件中您的组件带有离子日期选择器

Use the below code in your .ts file where you have your component with ion date picker

ionViewWillLeave(){
        let backDrop: any = document.getElementsByTagName('ion-picker-cmp');
        if(backDrop.length > 0){
            for(let i = 0; i< backDrop.length; i++){
                backDrop[i].style.display = 'none';
            }
        }
      }

这篇关于关闭ionic2 datetime弹出窗口,同时按下返回按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆