Created
December 7, 2021 04:28
-
-
Save farithadnan/2f09fadda4973519f47c79cb505a541c to your computer and use it in GitHub Desktop.
Patching form group value into an Array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Patch value to default | |
displayData: string[]; | |
patchCreateAsDefault(mainControl: FormGroup): void { | |
// Check if the formgroup is valid or not first | |
if (mainControl.valid) { | |
// Get raw value of formgroup, for nested form | |
const formObj = mainControl.getRawValue(); | |
// Assign a new reference | |
const serializeForm = JSON.stringify(formObj); | |
// Push/assign to Array (current: push) | |
this.displayData.push(JSON.parse(serializeForm)); | |
// Assign | |
// this.displayData = JSON.parse( | |
// JSON.stringify(this.defaultData) | |
// ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment