Sorry for this question. This is to do with one of my child component which rejecting null, empty string while writing to form.
I have a form control orderNo.
When I try to dothis.myForm.controls['orderNo'].setValue = '123';
It works fine and my view is updated with this value.
But the issue is, I am not able to set the control with null or empty string. Whenever I dothis.myForm.controls['orderNo'].setValue = null;
orthis.myForm.controls['orderNo'].setValue = '';
it doesn't reflect on my view.
But I could see the form control holds that null value. (ng.probe($0).componentInstance.myForm.controls['orderNo'].value returns null).
It is just not being reflected on the view.
Please help me with some thoughts. Thank you.
You can directly use patchValue to set value of form fields
this.myForm.patchValue( {'orderNo':null} );
Below resets entire formgroup to null
this.myForm.reset();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With