1
1
import { Component , ViewChild , ViewChildren , QueryList , DebugElement } from '@angular/core' ;
2
2
import { TestBed , fakeAsync , tick , waitForAsync } from '@angular/core/testing' ;
3
- import { FormsModule , UntypedFormBuilder , ReactiveFormsModule , Validators , UntypedFormControl , UntypedFormGroup } from '@angular/forms' ;
3
+ import { FormsModule , UntypedFormBuilder , ReactiveFormsModule , Validators , UntypedFormControl , UntypedFormGroup , FormControl } from '@angular/forms' ;
4
4
import { By } from '@angular/platform-browser' ;
5
5
import { IgxInputGroupComponent , IgxInputGroupModule } from '../../input-group/input-group.component' ;
6
6
import { IgxInputDirective , IgxInputState } from './input.directive' ;
@@ -266,10 +266,10 @@ describe('IgxInput', () => {
266
266
fixture . detectChanges ( ) ;
267
267
268
268
const invalidInputGroups = fixture . debugElement . nativeElement . querySelectorAll ( `.igx-input-group--invalid` ) ;
269
- expect ( invalidInputGroups . length ) . toBe ( 4 ) ;
269
+ expect ( invalidInputGroups . length ) . toBe ( 6 ) ;
270
270
271
271
const requiredInputGroups = fixture . debugElement . nativeElement . querySelectorAll ( `.igx-input-group--required` ) ;
272
- expect ( requiredInputGroups . length ) . toBe ( 4 ) ;
272
+ expect ( requiredInputGroups . length ) . toBe ( 6 ) ;
273
273
} ) ;
274
274
275
275
it ( 'When updating two inputs with same attribute names through ngModel, label should responds' , fakeAsync ( ( ) => {
@@ -1033,7 +1033,20 @@ class DataBoundDisabledInputWithoutValueComponent extends DataBoundDisabledInput
1033
1033
<input type="number" formControlName="num" igxInput igxMask="###">
1034
1034
</igx-input-group>
1035
1035
</section>
1036
- </form>`
1036
+ </form>
1037
+ <form>
1038
+ <section>
1039
+ <igx-input-group>
1040
+ <label igxLabel>single line</label>
1041
+ <input type="text" [formControl]="inputControl" igxInput>
1042
+ </igx-input-group>
1043
+ <igx-input-group>
1044
+ <label igxLabel>multi line</label>
1045
+ <textarea type="text" [formControl]="textareaControl" igxInput></textarea>
1046
+ </igx-input-group>
1047
+ </section>
1048
+ </form>
1049
+ `
1037
1050
} )
1038
1051
class ReactiveFormComponent {
1039
1052
@ViewChild ( 'strinput' , { static : true , read : IgxInputDirective } ) public strIgxInput : IgxInputDirective ;
@@ -1045,6 +1058,9 @@ class ReactiveFormComponent {
1045
1058
num : [ null , Validators . required ]
1046
1059
} ) ;
1047
1060
1061
+ public inputControl = new FormControl ( '' , [ Validators . required ] ) ;
1062
+ public textareaControl = new FormControl ( '' , [ Validators . required ] ) ;
1063
+
1048
1064
constructor ( private fb : UntypedFormBuilder ) { }
1049
1065
1050
1066
public markAsTouched ( ) {
@@ -1056,6 +1072,12 @@ class ReactiveFormComponent {
1056
1072
}
1057
1073
}
1058
1074
}
1075
+
1076
+ this . inputControl . markAsTouched ( ) ;
1077
+ this . inputControl . updateValueAndValidity ( ) ;
1078
+
1079
+ this . textareaControl . markAsTouched ( ) ;
1080
+ this . textareaControl . updateValueAndValidity ( ) ;
1059
1081
}
1060
1082
}
1061
1083
0 commit comments