Skip to content
Advertisement

Send formArray as one object

I am using mat-stepper single form for my stepper. when i do API call it sends data as an array of objects like this:

JavaScript

I would like to send data as one object like this:

JavaScript

this is my form:

JavaScript

service.ts

JavaScript

how can i do it?

Advertisement

Answer

You can use a simple transformation using javascript reduce function to transform the data to the desired structure

JavaScript

In your case this can be implemented like below

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement