I am trying to get a name of a component from a json file and via a method add 'this'
to its name.
import { MyComponent } from './Mycomponent';
...
MyComponent = MyComponent;
data = [
{
"name": "MyComponent"
}
];
The method:
test(name: any) {
return this.[name];
}
usage example:
this.test('MyComponent');
Expected output is:
this.MyComponent
When I try: this.[name]
I get Identifier expected.
How can I fix this?