Issue
I need to keep the object like this:
{
"name": "test",
"parent": {
"id": "70abe1d4-cd03-4987-8bb3-6adf35d82cf9"
}
}
I've tried it this way, but it doesn't work.
initializeForm(): void {
this.form = this.fb.group(
{
name: new FormControl('', Validators.required),
parent: {
id: new FormControl(this.parent)
}
}
);
}
Solution
Angular Reactive Form supports multiple form groups. Doc
this.form = this.fb.group(
{
name: new FormControl('', Validators.required),
parent: this.fb.group({
id: ['', Validators.required]
})
}
);
Answered By - Tagi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.