From ed8be5210c6879a44d5cde823727a7527adb9022 Mon Sep 17 00:00:00 2001 From: Trotyl Date: Mon, 11 Dec 2017 15:09:42 +0800 Subject: [PATCH] fix(module:datepicker): enable simplified boolean usage --- .../datepicker/nz-datepicker.component.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/datepicker/nz-datepicker.component.ts b/src/components/datepicker/nz-datepicker.component.ts index a4f1f6184d..34f0a01c92 100644 --- a/src/components/datepicker/nz-datepicker.component.ts +++ b/src/components/datepicker/nz-datepicker.component.ts @@ -191,6 +191,7 @@ import { toBoolean } from '../util/convert'; export class NzDatePickerComponent implements ControlValueAccessor, OnInit { private _allowClear = true; private _disabled = false; + private _showTime: Partial = null; _el: HTMLElement; _open = false; _mode = 'year'; @@ -210,7 +211,6 @@ export class NzDatePickerComponent implements ControlValueAccessor, OnInit { // ngModel Access onChange: (value: Date) => void = () => null; onTouched: () => void = () => null; - @Input() nzShowTime = null; @Input() nzPlaceHolder = this._locale.translate('DateTime.chooseDatePlease'); @Input() nzFormat = 'YYYY-MM-DD'; @Input() nzSize = ''; @@ -218,6 +218,19 @@ export class NzDatePickerComponent implements ControlValueAccessor, OnInit { @ViewChild('trigger') trigger; @ViewChild(NzTimePickerInnerComponent) timePickerInner: NzTimePickerInnerComponent; + @Input() + set nzShowTime(value: Partial) { + if (typeof value === 'string' || typeof value === 'boolean') { + this._showTime = toBoolean(value) ? {} : null; + } else { + this._showTime = value; + } + } + + get nzShowTime(): Partial { + return this._showTime; + } + @Input() set nzAllowClear(value: boolean) { this._allowClear = toBoolean(value);