OnDestroy shouldn't set the FormControl value to null
See original GitHub issueThe ngOnDestroy
method
public ngOnDestroy(): void {
this.fg = null;
if (this.subscription) {
this.subscription.unsubscribe();
}
if (this.onChange) {
this.onChange(null);
}
}
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) {
this.onChange(null);
}
should be removed.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (1 by maintainers)
Top 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 >FormControlName
Syncs a FormControl in an existing FormGroup to a form control element by name. ... register multiple form controls within a form group...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 😃
@fadisdh you can track the new issue here
https://github.com/cloudnc/ngx-sub-form/issues/56