I'm struggling with the following task.
On the one hand I have the following object:
[
{
name: "VALUE1",
type: "select",
label: "Label"
},
{
name: "VALUE2",
type: "select",
label: "Label"
},
{
name: "VALUE3",
type: "select",
label: "Label"
},
];
On the other hand I have some content for the object above, with I want to merge in a new object.
Here's the content:
[
{
VALUE1: "CONTENT",
VALUE2: "CONTENT",
VALUE3: "CONTENT",
VALUE4: "CONTENT",
VALUE5: "CONTENT",
},
{
VALUE1: "CONTENT",
VALUE2: "CONTENT",
VALUE3: "CONTENT",
VALUE4: "CONTENT",
VALUE5: "CONTENT",
},
{
VALUE1: "CONTENT",
VALUE2: "CONTENT",
VALUE3: "CONTENT",
VALUE4: "CONTENT",
VALUE5: "CONTENT",
}
]
Please notice that the key from the second object matches with the value from the first
At the end I need a object which should have the following structure:
[
{
name: 'VALUE1'
id: 'CONTENT 1 ',
label: 'LABEL 1',
type: 'select'
selectMenuOptions: {
VALUE1: "CONTENT",
VALUE1: "CONTENT",
VALUE1: "CONTENT",
VALUE1: "CONTENT",
VALUE1: "CONTENT",
}
},
{
name: 'VALUE2'
id: 'CONTENT 2 ',
label: 'LABEL 2',
type: 'select'
selectMenuOptions: {
VALUE2: "CONTENT",
VALUE2: "CONTENT",
VALUE2: "CONTENT",
VALUE2: "CONTENT",
VALUE2: "CONTENT",
}
},
{
name: 'VALUE3'
id: 'CONTENT 3 ',
label: 'LABEL 3',
type: 'select'
selectMenuOptions: {
VALUE3: "CONTENT",
VALUE3: "CONTENT",
VALUE3: "CONTENT",
VALUE3: "CONTENT",
VALUE3: "CONTENT",
}
},
]
Some background information if it helps:
- Angular 14
- The object I try to form is for dynamic forms