Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 FormGroup disabled field value

Tags:

I have a reactive form. One field is disabled, so how do i get that value from the form in controller? Writing the the FormGroup to console it doesnt display the disabled field at all, even tho it's displayed in the view.

like image 816
TuomasK Avatar asked Oct 31 '16 12:10

TuomasK


People also ask

How do I turn off form control and keep value?

If you set disabled to true when you set up this control in your component class, the disabled attribute will actually be set in the DOM for you. We recommend using this approach to avoid 'changed after checked' errors. Example: form = new FormGroup({ first: new FormControl({value: 'Nancy', disabled: true}, Validators.


1 Answers

Use the FormGroup's getRawValue() to include control values regardless of enable/disable state.

More information in the API documentation

like image 134
silentsod Avatar answered Oct 05 '22 15:10

silentsod