I am using dependent LWC and from a lower level I am passing an array to its parent. I first tried by hardcoding the array and that worked ok
@track testmap=[{'Id':'01t6700000Cwxot','Name':'Product1'},{'Id':'01t6700000CwxjY','Name':'Product2'}];
Now I am building this dynamically when some click happens and I build a string that I turn or try to turn into the format that works above but it doesn't. I thought Split would do but I am wrong or doing something stupid that I can't see anymore..
How can I convert my concatenation into the good format of my testmap?
this.clickedAddSpot=this.clickedAddSpot+','+ "{'id':'"+this.record.prod_id__c+"','Name':'"+this.record.prod_name__c+"'}";
if(this.clickedAddSpot.substring(0, 1)==','){
this.clickedAddSpot = this.clickedAddSpot.substring(1);
console.log('title ' + this.clickedAddSpot);
}
this.selSpot = this.clickedAddSpot.split(',');
console.log('showRowDetails the array is :' +this.selSpot);
Here is the output in Java console
showRowDetails the array is :{'Id':'01t6700000Cwxot','Name':'Product1'},{'Id':'01t6700000CwxjY','Name':'Product2'}