is there a way to compose the key value of an object in typescript from strings? Here's an example:
object[index].key=value
should be,
object[index].["String".array[i]]=value
The following does not work:
{{ object[index].{{"string".concat(Variable[index])}} }} <-- the rendering is perfectly fine but the execution is missing
I'm trying to read an object in two "ngFor" loops, with the first loop acting as a counter for an array whose element acts as a key for the object in the second loop.
thx
EDIT:
tage=['Montag','Dienstag','Mittwoch']
objectArray: {
id:Number;
name:String;
Montag:String;
Dienstag:String;
Mittwoch:String;
}[]=[
{id:0,name:'Klaus',Montag:'arbeiten',Dienstag:'rumgammeln',Mittwoch:'Frei'},
{id:1,name:'Dieter',Montag:'frei',Dienstag:'arbeiten',Mittwoch:'rumgammeln'},
{id:2,name:'Peter',Montag:'rumgammeln',Dienstag:'frei',Mittwoch:'arbeiten'},
]
Template
1:{{objectArray[0].Montag}}<br>
2:{{objectArray[0]['Montag']}}<br>
<br>
<ng-container *ngFor="let tag of tage; let i=index">
{{i}}:{{objectArray[0][tage[i]]}}<br> <------- NOT WORKING
</ng-container>
Error Message
(property) AppComponent.tage: string[]
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ id: Number; name: String; Montag: String; Dienstag: String; Mittwoch: String; }'.
No index signature with a parameter of type 'string' was found on type '{ id: Number; name: String; Montag: String; Dienstag: String; Mittwoch: String; }'.ngtsc(7053)
app.component.ts(8, 53): Error occurs in the template of component AppComponent.