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.

OnDestroy shouldn't set the FormControl value to null

See original GitHub issue

Issue Description

The ngOnDestroy method

public ngOnDestroy(): void {
  this.fg = null;

  if (this.subscription) {

  if (this.onChange) {

currently sets the original FormControl value to null. I’d say it’s not really the responsibility of the library to set that value to null, thus

if (this.onChange) {

should be removed.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

fadisdhcommented, Jun 17, 2019

Thank you, this helped a lot with tabbed forms (as I don’t want to lose the data whenever the tab gets changed and components get destroyed)

Didn’t find documentation for it though, saw the closed issue while trying to write a new one. can you please add it in the Readme file? Thx again 😃

maxime1992commented, Jun 17, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cleanest way to reset forms - angular
All the fields will be reset to null. But, if instead, we use NonNullableFormBuilder , all the fields will be reset to its...
Read more >
Document the usage of `emitNullOnDestroy` and ` ...
OnDestroy shouldn't set the FormControl value to null #21 ... doc(lib): describe usage for emitNullOnDestroy and `emitInitialValu…
Read more >
A thorough exploration of Angular Forms
when user is typing into an input: View -> Model; when the value is set programmatically( FormControl.setValue('newValue') ): Model -> View.
Read more >
Creating a custom form control in Angular - Orjan De Smet
If you'd just use these directives, you'd get the error “No value accessor for form control with name: <the name of your control>”....
Read more >
Syncs a FormControl in an existing FormGroup to a form control element by name. ... register multiple form controls within a form group...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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 Post

No results found

github_iconTop Related Hashnode Post

No results found