I am using Reactive FormsModule
in Angular2
. Now, I want to disable all controls of FormGroup
. I can use readOnly
property in all controls but it is not better solution as we might add new fields in near future.
So, Is there anyway to disable FormGroup
controls in short ?
Warning: if anyone is calling disable() inside of a an observable which is watching for changes on the form, you will want to pass in the argument {emitEvent: false}
like
control.disable({emitEvent: false});
This helped me avoid a Maximum call stack size exceeded
Error.
Now, I want to disable all controls of FormGroup
Use disable():
YOUR_FORM_GROUP.disable();
DEMO
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