From 244c5d2a36e04922f42717529455d222658c8788 Mon Sep 17 00:00:00 2001 From: vthinkxie Date: Wed, 11 Sep 2019 15:11:19 +0800 Subject: [PATCH] fix(module:select): fix select compareWith array not work close #4139 --- components/select/nz-select.component.ts | 2 +- components/select/nz-select.service.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/select/nz-select.component.ts b/components/select/nz-select.component.ts index 3554b5a988a..dd4af8b65c1 100644 --- a/components/select/nz-select.component.ts +++ b/components/select/nz-select.component.ts @@ -273,7 +273,7 @@ export class NzSelectComponent implements ControlValueAccessor, OnInit, AfterVie this.value = value; let listValue: any[] = []; // tslint:disable-line:no-any if (isNotNil(value)) { - if (Array.isArray(value)) { + if (this.nzSelectService.isMultipleOrTags) { listValue = value; } else { listValue = [value]; diff --git a/components/select/nz-select.service.ts b/components/select/nz-select.service.ts index 8c0e82ec718..56bb7d37810 100644 --- a/components/select/nz-select.service.ts +++ b/components/select/nz-select.service.ts @@ -101,9 +101,10 @@ export class NzSelectService { // selected value or ViewChildren change valueOrOption$ = combineLatest([this.listOfSelectedValue$, this.mapOfTemplateOption$]).pipe( tap(data => { - this.listOfSelectedValue = data[0]; - this.listOfNzOptionComponent = data[1].listOfNzOptionComponent; - this.listOfNzOptionGroupComponent = data[1].listOfNzOptionGroupComponent; + const [listOfSelectedValue, mapOfTemplateOption] = data; + this.listOfSelectedValue = listOfSelectedValue; + this.listOfNzOptionComponent = mapOfTemplateOption.listOfNzOptionComponent; + this.listOfNzOptionGroupComponent = mapOfTemplateOption.listOfNzOptionGroupComponent; this.listOfTemplateOption = this.listOfNzOptionComponent.concat( this.listOfNzOptionGroupComponent.reduce( (pre, cur) => [...pre, ...cur.listOfNzOptionComponent.toArray()],