Skip to content

Commit

Permalink
fix(module:select): error caused by value of sync (#338)
Browse files Browse the repository at this point in the history
close #326
  • Loading branch information
hsuanxyz authored and vthinkxie committed Sep 22, 2017
1 parent d5d379b commit cfcdef1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/components/select/nz-option.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {
Component,
ViewEncapsulation,
Input,
OnDestroy
OnDestroy,
OnInit
} from '@angular/core';

import { NzSelectComponent } from './nz-select.component';
Expand All @@ -15,7 +16,8 @@ import { NzSelectComponent } from './nz-select.component';
`,
styleUrls : []
})
export class NzOptionComponent implements OnDestroy {
export class NzOptionComponent implements OnDestroy, OnInit {

_value: string;
_label: string;
_disabled = false;
Expand Down Expand Up @@ -54,6 +56,9 @@ export class NzOptionComponent implements OnDestroy {
}

constructor(private _nzSelect: NzSelectComponent) {
}

ngOnInit(): void {
this._nzSelect.addOption(this);
}

Expand Down
7 changes: 5 additions & 2 deletions src/components/select/nz-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ export class NzSelectComponent implements OnInit, AfterContentInit, AfterContent
addOption = (option) => {
this._options.push(option);
if (!this._isTags) {
this.forceUpdateSelectedOption(this._value);
if (option.nzValue) {
this.updateSelectedOption(this._value);
} else {
this.forceUpdateSelectedOption(this._value);
}
}
}

Expand Down Expand Up @@ -672,7 +676,6 @@ export class NzSelectComponent implements OnInit, AfterContentInit, AfterContent
}

writeValue(value: any): void {
// this.nzValue = value;
this._updateValue(value, false);
}

Expand Down

0 comments on commit cfcdef1

Please sign in to comment.