In my component, I have the following function:
updateInfo(info: NgForm) {
const changedValues = Object.keys(info.controls)
.filter(key => info.controls[key].dirty === true)
.map(key => {
return { control: key, value: info.controls[key].value }
});
console.log(changedValues);
}
This function logs the changes in form values, but now I want to create an array using changedValues
like this:
{ firstName: "john", lastName: "sam" }
How can I achieve that?
Edit: Currently, the console log output looks like this
[
{firstName: "john"},
{lastName: "sam"}
]