In an attempt to generate JSON data in an array for passing to another component, I followed a method outlined below. However, being relatively new to this field, my execution may not have been optimal as expected.
employeeMoney: any[] = [];
employeeId: any[] = [];
this.employeeMoney.push(event.target.value);
this.employeeId.push(employId);
The user-input data is processed by pushing it into the respective arrays created within the same function.
this.employeeMoney.map(function(item) {
blopp.all.money.push(item);
});
this.employeeId.map(function(item) {
blopp.all.id.push(item);
});
let blopp: any = {
all: [{id: '', money:''}]
};
My aim is to merge data from two separate arrays into a single list and then structure the JSON data as required. However, encountering an error when entering input data, with the following message displayed on the console:
ERROR ReferenceError: Cannot access 'blopp' before initialization
I am currently stuck at resolving this issue, attempting to create a JSON structure based on the latest data of money and id collected.
blopp.map(function(item: any) {
blopp.money.push({
"employee_id" : '',
"amount" : item,
"currency" : 'USD'
})
});
Furthermore, I am puzzled about how to include two different datasets within the same array list while maintaining the desired JSON structure.