I have a simple question.
I want to turn this array of one object…
[
{
id: 1,
caseId: "Default Case Set",
casenbr: "CASEWORK",
submitterCasenbr: 34,
othref: 0,
sta: 0,
type: 0,
create: 0,
startd: 0
}
]
into an array of multiple objects like this…
[
{
id: 1
},
{
caseId: "Default Case Set"
},
{
casenbr: "CASEWORK"
},
{
submitterCasenbr: 34
},
{
othref: 0
},
{
sta: 0
},
{
type: 0
},
{
create: 0
},
{
startd: 0
}
]
What would be the best approach to do this? Basically, I want to take all the key/value pairs in the object and turn them each into objects.
So, if I have an array of one object with 100 key/value pairs, I’d want to create one array of 100 objects that have only one key/value pair.
The reason I’m doing this is to create an array that I can use for an ngFor directive in my Angular 13 app.
I don’t know if there is a way for ngFor in Angular to repeat over the key/value pairs of one object in one array, so that’s what I’m creating one array of multiple objects.