Skip to content

Commit

Permalink
fix(Input): #3550 Abstracted the validity check to a method.
Browse files Browse the repository at this point in the history
  • Loading branch information
gedinakova committed Jan 10, 2019
1 parent b48af60 commit 0ec3343
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
@Input('value')
set value(value: any) {
this.nativeElement.value = value;
if (!this.ngControl && this._hasValidators) {
this._valid = this.nativeElement.checkValidity() ? IgxInputState.VALID : IgxInputState.INVALID;
}
this.checkValidity();
}
/**
* Gets the `value` propery.
Expand Down Expand Up @@ -147,9 +145,7 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
*/
@HostListener('input')
public onInput() {
if (!this.ngControl && this._hasValidators()) {
this._valid = this.nativeElement.checkValidity() ? IgxInputState.VALID : IgxInputState.INVALID;
}
this.checkValidity();
}
/**
*@hidden
Expand Down Expand Up @@ -297,4 +293,10 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
public set valid(value: IgxInputState) {
this._valid = value;
}

private checkValidity() {
if (!this.ngControl && this._hasValidators) {
this._valid = this.nativeElement.checkValidity() ? IgxInputState.VALID : IgxInputState.INVALID;
}
}
}

0 comments on commit 0ec3343

Please sign in to comment.