Q:

angular add formgroup to formgroup

this.form = this.fb.group({
  name: ['', [Validators.required]],
  contacts: this.fb.group({
    email: ['', [Validators.email]],
  })
});
<!-- name -->
<mat-grid-tile>
  <mat-form-field>
    <input matInput type="text" formControlName="name">
    <mat-error *ngIf="form.controls.name.hasError('required')">Name required</mat-error>
  </mat-form-field>
</mat-grid-tile>   
<!-- contacts -->
<div formGroupName="contacts">
	<!-- email -->
	<mat-grid-tile>
  		<mat-form-field>
    		<input matInput type="text" formControlName="email">
	    	<mat-error *ngIf="form.get('contacts').get('email').hasError('required')">Email required</mat-error>
		</mat-form-field>
	</mat-grid-tile>
</div>
0

New to Communities?

Join the community