javascript - How to close Ionic2 Datetime popup without clicking Cancel button -


in ionic 2 project, need make user logout after idle timeout. while doing so, noticed cannot close datetime popup before invoking logout event , redirecting login page. need close popup before redirecting login page. below code sample working on

<ion-datetime (ioncancel)="oncanceldatetime()" [(ngmodel)]="datetime">  </ion-datetime> 

the (ioncancel) event fired when close popup.

is there way invoke firing of event programmatically?

or there way close datetime popup?

currently there no official documented ionic 3 way close datetime picker programmatically.

however can use javascript 'dispatchevent' method trigger click on 'cancel' button of datetime picker.

here how it:

// reference clear button of datetime picker. var pickerclearbutton = document.getelementsbyclassname("picker-button")[0];  // create click event triggered var clickevent = new mouseevent("click", {     "view": window,     "bubbles": true,     "cancelable": false });  // trigger event pickerclearbutton.dispatchevent(clickevent); 

i believe job!!


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -