Angular 2 disabled controls do not get included in the form.value

后端 未结 4 1529
遥遥无期
遥遥无期 2020-12-07 14:41

I have noticed that if I disable a control on an Angular 2 reactive form then the control does not get included in the form.value. For example, if I define my form like bel

4条回答
  •  攒了一身酷
    2020-12-07 15:35

    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.

提交回复
热议问题