I have multiple forms in different components. I am using formBuilder to create my formGroups for typed forms. When I am passing the created formGroups to a child component through @Input, I don't see the type assertion passed. Is there a way to do this to know the type of a formControl.
Parent Component:
public form1 = this.formBuilder.group({ name: ["", Vaidators.required] enabled: [false, aidators.required] }); public form2= this.formBuilder.group({ date: ["", Vaidators.required] }); public form3 = this.formBuilder.group({ data: ["", Vaidators.required], recurring: [true, Vaidators.required] }); public form = this.formBuilder.group({ form1: this.form1, form2: this.form2, form3: this.form3, }); <child1 [form1]="form1"></child1> <child2 [form2]="form2"></child2> <child3 [form3]="form3"></child3> Child Component:
@Input() form1: FormGroup; <form [formGroup]="from1"> <input type="text" formControlName="name" /> </form> I know that I can create a Interface for each formGroup and use it in the child components. But, I would like to know if there is another way to do this.
interface form1 { name: FormControl<string>; } form: FormGroup<form1> = new FormGroup({ name: new FormControl("") })