Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior of FormControl's constructor, patchValue method, and undefined #29915

Senneseph opened this Issue Apr 15, 2019 · 0 comments


None yet
2 participants
Copy link

Senneseph commented Apr 15, 2019

馃悶 bug report

Affected Package

The issue is caused by package @angular/forms

Is this a regression?

Don't know.


When a FormControl is created via its constructor with a value of _undefined_, it is silently changed to _null_. When a FormControl has its value changed to _undefined_ via the patchValue() method, it takes the value _undefined_.

馃敩 Minimal Reproduction

馃實 Your Environment

Angular Version:

Angular CLI: 7.3.5
Node: 8.11.2
OS: linux x64
Angular: 7.2.12
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
@angular-devkit/architect         0.13.6
@angular-devkit/build-angular     0.13.6
@angular-devkit/build-optimizer   0.13.6
@angular-devkit/build-webpack     0.13.6
@angular-devkit/core              7.3.6
@angular-devkit/schematics        7.3.5 (cli-only)
@ngtools/webpack                  7.3.6
@schematics/angular               7.3.5 (cli-only)
@schematics/update                0.13.5 (cli-only)
rxjs                              6.4.0
typescript                        3.2.4
webpack                           4.29.0

Anything else relevant?

I understand that the constructor defaults the value to null if an argument isn't passed, but in this case, an argument is being passed, it's just undefined.

The use case I have here is, if there is a FormControl whose value is initially undefined, I don't want that entry to show up when I call FromGroup.value. Essentially, unless the is edited in some way, I don't want it to exist.

At the very least, the constructor and updating methods (patchValue, setValue) should behave in a similar way. For now, I am creating a FormControl and then immediately calling patchValue on it.

Is there some other way of passing in undefined that I've missed?

@ngbot ngbot bot added this to the needsTriage milestone Apr 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.