I have a current Array of objects that looks like this:
this.subsidiaryOptions = [
{ label: FILTER_LABELS.topLevelOrganization, value: '0', selected: !this.includeOpportunities },
{ label: FILTER_LABELS.currentOrganization, value: '1', selected: !this.includeOpportunities }
];
now I have this new array like this one - i'm trying to add these fields as labels in the other array or adapt this array to be like the original one:
this.engagementService.orgSubSidNames =
['a', 'b', 'c', 'd', 'f', 'g']
I want to either make the current array include each member of this new arrays members in it's label field and then have the 'values' increase by 1 for each one, and add all of them have a 'selected' field.
Or add the fields into this new array, the array's size is not static either it will change.
I tried to use a push method with the labels like this:
this.engagementService.orgSubSidNames.push.apply(this.engagementService.orgSubSidNames, this.subsidiaryOptions);
But couldnt get it to work, i was going to rap it in a for loop to increase the values but im getting an error on this push attempt.
expected result:
Either array = [
{ label: a, value: '0', selected: !this.includeOpportunities },
{ label: b, value: '1', selected: !this.includeOpportunities },
{ label: c, value: '2', selected: !this.includeOpportunities },
{ label: d, value: '3', selected: !this.includeOpportunities },
{ label: f, value: '4', selected: !this.includeOpportunities },
{ label: g, value: '5', selected: !this.includeOpportunities }
];