Skip to content

Commit 29d2a5f

Browse files
committed
chore: use FormGroup properly
1 parent f6e5f6f commit 29d2a5f

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
@@ -623,7 +623,7 @@ describe('MdInputContainer', function () {
623623
component = groupFixture.componentInstance;
624624
containerEl = groupFixture.debugElement.query(By.css('md-input-container')).nativeElement;
625625

626-
expect(component.formControl.invalid).toBe(true, 'Expected form control to be invalid');
626+
expect(component.formGroup.invalid).toBe(true, 'Expected form control to be invalid');
627627
expect(containerEl.querySelectorAll('md-error').length).toBe(0, 'Expected no error messages');
628628
expect(component.formGroupDirective.submitted)
629629
.toBe(false, 'Expected form not to have been submitted');
@@ -955,9 +955,9 @@ class MdInputContainerWithFormErrorMessages {
955955

956956
@Component({
957957
template: `
958-
<form [formGroup]="formGroup" (ngSubmit)="onSubmit()" novalidate>
958+
<form [formGroup]="formGroup" novalidate>
959959
<md-input-container>
960-
<input mdInput [formControl]="formControl">
960+
<input mdInput formControlName="name">
961961
<md-hint>Please type something</md-hint>
962962
<md-error>This field is required</md-error>
963963
</md-input-container>
@@ -966,7 +966,7 @@ class MdInputContainerWithFormErrorMessages {
966966
})
967967
class MdInputContainerWithFormGroupErrorMessages {
968968
@ViewChild(FormGroupDirective) formGroupDirective: FormGroupDirective;
969-
onSubmit() { }
970-
formControl = new FormControl('', Validators.required);
971-
formGroup = new FormGroup({ name: this.formControl });
969+
formGroup = new FormGroup({
970+
name: new FormControl('', Validators.required)
971+
});
972972
}

0 commit comments

Comments
 (0)