I followed this link: How do I dynamically assign properties to an object in TypeScript?
but it shows only how to handle object props names and values with long separate definition of an object. I wish to know how to do it with an "on the fly" anonymous built object of any type with no previous definition. I will show it in the following example.
can't make it to work. unfortunately it takes the variable name as the lable and not the variables value as I wish.
here is the code:
var srchTxtlabel: string = '';
if (this.labelType == '1')
srchTxtlabel = 'srchtxt';
else if (this.labelType == '2')
srchTxtlabel = 'subject';
this.myService.emit({
srchTxtlabel : this.val1,
'va2Label' : this.val2
})
Please help...