I was looking to create a dynamic interface with custom properties, like so:
data: dataInterface [];
this.data = [
{
label: {
text: 'something',
additionalInfo: 'something'
}
},
{
bar: {
text: 'something',
additionalInfo: 'something'
}
},
{
whatever: {
text: 'something',
additionalInfo: 'something'
}
},
];
The labels can be anything and there can be any number of items in the array.
I attempted the following approach:
export interface dataInterface {
[propName: string]: subDataInterface;
}
interface subDataInterface {
text: string;
additionalInfo: string;
}
However, this solution wasn't successful for me. My end goal is to modify the data like this:
this.dataInterface.bar.text = "another example text";
Any suggestions?