#ControlContainer.formDirective issues

4 messages · Page 1 of 1 (latest)

atomic pagoda
#

Hello, have created nested FormGroup with one FormGroup inside as well and child FormGroup have custom form control where i wanna programically submit the root FormGroup.
Isuue: i inject ControlContainer into my custom form control component and trying find something in this instance with ngSubmit to submit the root form. I have console logged the instance and checked what i have in browser and found that controlContainer.formDirective in browser have type FormGroupDirective but in ng documentation and in VSC its type is Form. I found a typing bug and i can just cast this property to FormGroupDirective and sleep well or problem not here mostprobably? Any ideas?

prime patrol
#

In your situation the type might always be that, but in other situations that might not be the case. Other types might implement the Form interface
https://angular.io/api/forms/Form

pine nebula
#

Why would you need to call ngSubmit()? Just add a button of type submit (but that's the default type anyway), and clicking it will submit the form. That's simply how HTML works.