Skip to content

Commit

Permalink
feat(module:select): support undefined reset select (#363)
Browse files Browse the repository at this point in the history
close #284
  • Loading branch information
vthinkxie authored Sep 22, 2017
1 parent ae06649 commit 1a997c2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/components/select/nz-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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 ]);
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}
Expand Down

0 comments on commit 1a997c2

Please sign in to comment.