Skip to content

Commit 7725dc7

Browse files
committed
chore: use FormGroup properly
1 parent 880a6a0 commit 7725dc7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lib/input/input-container.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ describe('MdInputContainer', function () {
620620
component = groupFixture.componentInstance;
621621
containerEl = groupFixture.debugElement.query(By.css('md-input-container')).nativeElement;
622622

623-
expect(component.formControl.invalid).toBe(true, 'Expected form control to be invalid');
623+
expect(component.formGroup.invalid).toBe(true, 'Expected form control to be invalid');
624624
expect(containerEl.querySelectorAll('md-error').length).toBe(0, 'Expected no error messages');
625625
expect(component.formGroupDirective.submitted)
626626
.toBe(false, 'Expected form not to have been submitted');
@@ -951,9 +951,9 @@ class MdInputContainerWithFormErrorMessages {
951951

952952
@Component({
953953
template: `
954-
<form [formGroup]="formGroup" (ngSubmit)="onSubmit()" novalidate>
954+
<form [formGroup]="formGroup" novalidate>
955955
<md-input-container>
956-
<input mdInput [formControl]="formControl">
956+
<input mdInput formControlName="name">
957957
<md-hint>Please type something</md-hint>
958958
<md-error>This field is required</md-error>
959959
</md-input-container>
@@ -962,9 +962,9 @@ class MdInputContainerWithFormErrorMessages {
962962
})
963963
class MdInputContainerWithFormGroupErrorMessages {
964964
@ViewChild(FormGroupDirective) formGroupDirective: FormGroupDirective;
965-
onSubmit() { }
966-
formControl = new FormControl('', Validators.required);
967-
formGroup = new FormGroup({ name: this.formControl });
965+
formGroup = new FormGroup({
966+
name: new FormControl('', Validators.required)
967+
});
968968
}
969969

970970
/**

0 commit comments

Comments
 (0)