From 1a997c2c1b47719e3f5054cc6d72b1230b045b54 Mon Sep 17 00:00:00 2001 From: VTHINKXIE Date: Sat, 23 Sep 2017 00:14:55 +0800 Subject: [PATCH] feat(module:select): support undefined reset select (#363) close #284 --- src/components/select/nz-select.component.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/select/nz-select.component.ts b/src/components/select/nz-select.component.ts index 4b81a2db895..ce99dc08a2c 100644 --- a/src/components/select/nz-select.component.ts +++ b/src/components/select/nz-select.component.ts @@ -458,12 +458,12 @@ export class NzSelectComponent implements OnInit, AfterContentInit, AfterContent /** update selected option when add remove option etc */ updateSelectedOption(currentModelValue, triggerByNgModel = false) { - if (currentModelValue === null || currentModelValue === undefined) { + if (currentModelValue == null) { return; } if (this.nzMultiple) { const selectedOptions = this._options.filter((item) => { - return ((item !== null) && (item !== undefined)) && (currentModelValue.indexOf(item.nzValue) !== -1); + return (item != null) && (currentModelValue.indexOf(item.nzValue) !== -1); }); if ((this.nzKeepUnListOptions || this.nzTags) && (!triggerByNgModel)) { selectedOptions.forEach(option => { @@ -480,7 +480,7 @@ export class NzSelectComponent implements OnInit, AfterContentInit, AfterContent } else { const selectedOption = this._options.filter((item) => { - return (item !== null) && (item.nzValue === currentModelValue); + return (item != null) && (item.nzValue === currentModelValue); }); this.chooseOption(selectedOption[ 0 ]); } @@ -721,13 +721,13 @@ export class NzSelectComponent implements OnInit, AfterContentInit, AfterContent if (this._value === value) { return; } - if ((value === null) && this.nzMultiple) { + if ((value == null) && this.nzMultiple) { this._value = []; } else { this._value = value; } if (!this.nzMultiple) { - if (value === null) { + if (value == null) { this._selectedOption = null; } else { this.updateSelectedOption(value); @@ -739,7 +739,7 @@ export class NzSelectComponent implements OnInit, AfterContentInit, AfterContent } else { this.updateSelectedOption(value, true); } - } else if (value === null) { + } else if (value == null) { this.clearAllSelectedOption(emitChange); } }