Skip to content

Commit

Permalink
fix(module:select): fix select not change after option input changes (#…
Browse files Browse the repository at this point in the history
…3313)

close #3029
  • Loading branch information
vthinkxie authored Apr 19, 2019
1 parent c22eae5 commit 74d996b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions components/select/nz-option.component.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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<void>;
@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();
}
}
1 change: 1 addition & 0 deletions components/select/nz-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit 74d996b

Please sign in to comment.