I'm not sure if the question is related to Angular 2 or more with Typescript. But anyway, I have a component that emits an object
<grid" (gridButtonClickEvent)="gridEvent($event)"></grid>
This is how I caught the event
private gridEvent(event) { console.log(event); }
Here is the event format that I get.
{Key: value}
So basically this is a simple object. I want to call a function called Key
and pass a value
as an argument, how is this possible? The Key
object will be different, but I know all the possible options and an already registered function in my component.
private Key() {}
I tried something like this
private gridEvent(event) { let eventName = Object.keys(event)[0]; window[eventName](); }
But he says
window[eventName] is not a function
source share