Skip to content

Commit

Permalink
fixed #2161
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrtcndkn committed Feb 28, 2017
1 parent 087c358 commit 642f59d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions components/spinner/spinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export class Spinner implements OnInit,ControlValueAccessor {
@Input() thousandSeparator: string = ',';

@Input() tabindex: number;

@Input() formatInput: boolean = true;

value: number;

Expand Down Expand Up @@ -204,7 +206,11 @@ export class Spinner implements OnInit,ControlValueAccessor {

parseValue(val: string): number {
let value: number;
val = val.split(this.thousandSeparator).join('');

if(this.formatInput) {
val = val.split(this.thousandSeparator).join('');
}

if(val.trim() === '') {
value= this.min !== undefined ? this.min : null;
}
Expand Down Expand Up @@ -236,7 +242,10 @@ export class Spinner implements OnInit,ControlValueAccessor {
formatValue(): void {
if(this.value !== null && this.value !== undefined) {
let textValue = String(this.value).replace('.', this.decimalSeparator);
textValue = textValue.replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandSeparator);

if (this.formatInput) {
textValue = textValue.replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandSeparator);
}
this.valueAsString = textValue;
}
else {
Expand Down

0 comments on commit 642f59d

Please sign in to comment.