angular break sub array values to main object. subarray size is dynamic
myArray = [{'ID' : 1,
'addDetail' : ['test 1', 'test 2']}]
expected array
myArray = [{'ID' : 1, 'line1' : 'test 1', 'line2' : 'test 2'
'addDetail' : ['test 1', 'test 2']}]
i used bellow login
this.partiesdatalist = this.partiesdatalist.map(item => {
const addDetail = item.addDetail;
addDetail?.forEach((detail, index) => {
item[`line${index + 1}`] = detail;
});
return item;
});
but it showing error
Element implicitly has an ‘any’ type because expression of type ‘line${number}
‘ can’t be used to index type
in the line of
item[`line${index + 1}`] = detail;