I have problem with selecting variables predefined in component. these are variables:
public editable1: number = 0;
public editable2: number = 0;
public editable3: number = 0;
public editable4: number = 0;
public editable5: number = 0;
next array of arrays:
public editors: []=[
['editable1', 'editable3', 'editable5'],
['editable1', 'editable2', 'editable3']
]
eventually i would like to increment variables according to lists provided in array
this.editors.forEach(element => {
element.forEach(e => {
this['e'] ; // this suppose to be pointing to predefined variables, but it does not
});
});
how can I solve it?
CodePudding user response:
You can cast your component as any, and then you can access its properties with ['prop_name'] sytnax:
this.editors.forEach((element) => {
element.forEach((e) => {
(this as any)[e] ;
});
});