question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

formGroup disable()/enable() does not work right after init

See original GitHub issue

I’m submitting a…


[x] Bug report  

Current behavior

I you create a formGroup using formBuilder.group() and call formGroup.disable() or formGroup.enable() right after initialization then it doesn’t work. If you call it using button or setTimeout() then it works.

Expected behavior

Would be nice to be able to disable/enable form right after creation.

Minimal reproduction of the problem with instructions

View: https://ng-form-disable-after-init.stackblitz.io Edit: https://stackblitz.com/edit/ng-form-disable-after-init

Environment

Angular version: 5.2.7

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:66
  • Comments:42 (2 by maintainers)

github_iconTop GitHub Comments

30reactions
Xambeycommented, Feb 17, 2020

Same issue on 8.2.14 image

23reactions
ptrzynacommented, May 6, 2019

Version 8 is about to drop…is this bug going to be addressed? I noticed that the severity of this bug is marked as ‘inconvenient’. I wouldn’t say that it’s inconvenient. It essentially breaks the first precept of reactive forms where they are supposed to be synchronous. Somehow a race condition is occurring in ‘synchronous’ code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 4 - Reactive Forms enable/disable not working
You just need enable/disable methods of form control. Here is stackblitz example. It works perfectly. @Component({ selector: 'my-app', ...
Read more >
How to disable/enable an Angular FormGroup after init - Medium
This content highlight a simple solution to enable/disable a FormGroup in Angular. By adding the bold line below between the creation and the...
Read more >
Exploring the difference between disabling a form control ...
I'm using formGroup and formControlName directives from Reactive Forms API here. Using the FormControl's disable() instance method. Link to this section. This ...
Read more >
Angular Reactive Forms: Tips and Tricks | by Netanel Basal
There might be cases when we don't want to invalidate the form just because a single control ... Whenever we call a control's...
Read more >
AbstractControl - Angular
A control is enabled as long as its status is not DISABLED . ... call enable() or disable() without passing along {emitEvent: false}...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found