I have an array of JavaScript objects in one of my components
@Component(stuff)
export class ComponentName {
arrayOfObjects = [];
// stuff
}
in which each object has the keys key1
and key2
.
What I would like is to have an array arrayOfSubobjects
in ComponentName
whose contents are
{
key1: 'value1',
key2: 'value2'
}
for each pair of key1
and key2
that reside within the same object in arrayOfObjects
.
Moreover, if the value of key1
updates within an object in arrayOfObjects
, it has to be reflected in arrayOfSubobjects
. Same thing with key2
.
Note that arrayOfObjects
is subject to losing/gaining objects.