Skip to content

Commit

Permalink
fix(module:input-number): fix display value after formatter changed
Browse files Browse the repository at this point in the history
  • Loading branch information
csyszf committed Apr 25, 2018
1 parent e881ebd commit 451c787
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion components/input-number/nz-input-number.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class NzInputNumberComponent implements ControlValueAccessor, AfterViewIn
private _step = 1;
private autoStepTimer;
private _autoFocus = false;
private _formatter = (value) => value;
displayValue: string | number;
actualValue: string | number;
isFocused = false;
Expand All @@ -82,7 +83,6 @@ export class NzInputNumberComponent implements ControlValueAccessor, AfterViewIn
@Input() nzSize: 'small' | 'default' | 'large' = 'default';
@Input() nzMin: number = -Infinity;
@Input() nzMax: number = Infinity;
@Input() nzFormatter = (value) => value;
@Input() nzParser = (value) => value;
@Input() nzPrecision: number;

Expand Down Expand Up @@ -125,6 +125,16 @@ export class NzInputNumberComponent implements ControlValueAccessor, AfterViewIn
return this._step;
}

@Input()
set nzFormatter(v: (any) => any) {
this._formatter = v;
this.writeValue(Number(this.actualValue));
}

get nzFormatter(): (any) => any {
return this._formatter;
}

updateAutoFocus(): void {
if (this.isInit) {
if (this.nzAutoFocus) {
Expand Down

0 comments on commit 451c787

Please sign in to comment.