Reputation: 5757
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 ?
Upvotes: 17
Views: 42613
Reputation: 661
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.
Upvotes: 11
Reputation: 24864
Now, I want to disable all controls of FormGroup
Use disable():
YOUR_FORM_GROUP.disable();
Upvotes: 50