diff --git a/components/select/nz-option.component.ts b/components/select/nz-option.component.ts index 1626d2185d1..ee5c13822b0 100644 --- a/components/select/nz-option.component.ts +++ b/components/select/nz-option.component.ts @@ -1,6 +1,15 @@ -import { ChangeDetectionStrategy, Component, Input, TemplateRef, ViewChild, ViewEncapsulation } from '@angular/core'; +import { + ChangeDetectionStrategy, + Component, + Input, + OnChanges, + TemplateRef, + ViewChild, + ViewEncapsulation +} from '@angular/core'; import { InputBoolean } from 'ng-zorro-antd/core'; +import { Subject } from 'rxjs'; @Component({ selector: 'nz-option', @@ -9,11 +18,16 @@ import { InputBoolean } from 'ng-zorro-antd/core'; changeDetection: ChangeDetectionStrategy.OnPush, templateUrl: './nz-option.component.html' }) -export class NzOptionComponent { +export class NzOptionComponent implements OnChanges { + changes = new Subject(); @ViewChild(TemplateRef) template: TemplateRef; @Input() nzLabel: string; // tslint:disable-next-line:no-any @Input() nzValue: any; @Input() @InputBoolean() nzDisabled = false; @Input() @InputBoolean() nzCustomContent = false; + + ngOnChanges(): void { + this.changes.next(); + } } diff --git a/components/select/nz-select.component.ts b/components/select/nz-select.component.ts index 2156e8d073f..fe84323c969 100644 --- a/components/select/nz-select.component.ts +++ b/components/select/nz-select.component.ts @@ -326,6 +326,7 @@ export class NzSelectComponent implements ControlValueAccessor, OnInit, AfterVie merge( this.listOfNzOptionGroupComponent.changes, this.listOfNzOptionComponent.changes, + ...this.listOfNzOptionComponent.map(option => option.changes), ...this.listOfNzOptionGroupComponent.map(group => group.listOfNzOptionComponent ? group.listOfNzOptionComponent.changes : EMPTY )