-
Notifications
You must be signed in to change notification settings - Fork 78
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Default value in propObject not creating any property #551
Comments
@Tim-mhn The feature is available in 2.1.7 version. Here are the two ways to set the default value. The object will be created automatically @propObject(Address, { autoCreate:true }) you can pass the default value of the object. @propObject(Address, { defaultValue: new Address(...) }) |
Hi! One more scenario :-) It is not set, if propObject is inside other propObject. class Contact{ I get error: Cannot access 'Address' before initialization |
Describe the bug
I'm creating a form model with rxweb/reactive-form-validators with a nested property. The documentation suggests to manually create a value for this in the component such as this
user.model.ts
app.component.ts
I would very much like to avoid creating an object for each nested properties of my user model and automatically provide a default value when creating the user object. I see that
propObject
has adefaultValue
option but it doesn't seem to be working. Indeed, when i calluser.address
isnull
and the formGroup doesn't hold anyaddress
formgroup.Expected Behavior
Automatically, set a value for a nested property from the value provided in
propObject
'sdefaultValue
without the need to manually create an object.To Reproduce
You can check out the stackblitz link and comment out line. 22 in app.component.ts. You can see that, in this case,
user.address
doesn't exist and, thus, the formGroup doesn't have aaddress
sub-formGroup.Url (stackblitz or plunker or other)
https://stackblitz.com/edit/angular-ivy-k2y7d3?file=src/app/app.component.ts
Package Version
@rxwebrxweb/[email protected]
Thanks for your help !
The text was updated successfully, but these errors were encountered: