We can use disable() and enable() method of FormControl . We can also call disable/enable function at runtime by using control[action]() method of FormControl . We need to pass action as 'disable' or 'enable'. We can also use [disabled]="true" binding to disable a form control.
You can use:
this.notelinkingForm.getRawValue()
From Angular docs:
If you'd like to include all values regardless of disabled status, use this method. Otherwise, the
value
property is the best way to get the value of the group.
Another option that I use is:
this.form.controls['LinkToPreceeding'].value;
Thank you @Sasxa for getting me 80% what I needed.
For those of you looking for a solution to the same problem but for nested forms I was able to solve by changing my usual
this.notelinkingForm.get('nestedForm').value
to
this.notelinkingForm.getRawValue().nestedForm
If you use readonly
instead of disabled
it's still not editable while the data will be included in the form. But that isn't possible in all cases. E.g. it's not available for radio buttons and checkboxes. See MDN web docs. In those cases you have to apply for the other solutions provided here.
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