fix(datetime): add open() method

fixes #14923
This commit is contained in:
Manu Mtz.-Almeida
2018-08-11 18:02:24 +02:00
parent 4047812258
commit f032769a6c

View File

@ -1,4 +1,4 @@
import { Component, Event, EventEmitter, Prop, State, Watch } from '@stencil/core';
import { Component, Event, EventEmitter, Prop, State, Watch, Method } from '@stencil/core';
import { CssClassMap, PickerColumn, PickerOptions, StyleEvent } from '../../interface';
import { clamp, deferEvent } from '../../utils/helpers';
@ -221,6 +221,18 @@ export class Datetime {
this.emitStyle();
}
@Method()
async open() {
if (this.disabled) {
return;
}
const pickerOptions = this.generatePickerOptions();
this.picker = await this.pickerCtrl.create(pickerOptions);
this.validate();
await this.picker.present();
}
private emitStyle() {
this.ionStyle.emit({
'interactive': true,
@ -235,18 +247,6 @@ export class Datetime {
this.updateText();
}
private async open() {
if (this.disabled) {
return;
}
const pickerOptions = this.generatePickerOptions();
this.picker = await this.pickerCtrl.create(pickerOptions);
this.validate();
await this.picker!.present();
}
private generatePickerOptions(): PickerOptions {
const pickerOptions: PickerOptions = {
...this.pickerOptions,