Skip to content

Commit

Permalink
fix(Form Input): Risolve un bug del type number relativo all'input di…
Browse files Browse the repository at this point in the history
… caratteri diversi da quelli nu

ref #66
  • Loading branch information
Mario Traetta committed Sep 3, 2018
1 parent 52f0998 commit 2983226
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
'form-control-plaintext' : readonly,
'autocomplete' : isAutocompletable()
}"
[attr.aria-labelledby]="note ? noteId : undefined"
[(ngModel)]="value"/>
[attr.aria-labelledby]="note ? noteId : undefined"/>
<span class="btn-eye"
*ngIf="isPasswordMode"
(click)="isPasswordVisible = !isPasswordVisible"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';
import { InputType, INPUT_TYPES } from '../models/InputType';
import { Util } from '../util/util';
import { isNumber } from 'util';

let identifier = 0;

Expand Down Expand Up @@ -45,6 +46,12 @@ export class FormInputComponent implements AfterContentInit, ControlValueAccesso
}
set type(value: any) {
if (InputType.is(value)) {
if (value === INPUT_TYPES.NUMBER) {
if (!isNumber(this.value)) {
this.value = '';
this.onChange();
}
}
this._type = value;
} else {
this._type = INPUT_TYPES.TEXT;
Expand Down

0 comments on commit 2983226

Please sign in to comment.