I have a child component with an input
tag
<input [formControl]="control">
component.ts file
@Input() control: FormControl;
And using it in the parent as
<app-input [control]="f['email']"></app-input>
~~~~~~~~~~
component.ts file
public form: FormGroup;
constructor(
private fb: FormBuilder,
) {
this.form = this.fb.group({
email: ['', [
Validators.email,
Validators.required
]],
});
}
get f() {
return this.form.controls;
}
But it is giving an error in the HTML control
assignment.
Type AbstractControl<any> is not assignable to type FormControl