I got a function name and want to call it inside Angular class (.ts file). eval() is not an option.
I have tried using window[functionName] , but it fails, guess because window context is outside the class
Any idea?
I got a function name and want to call it inside Angular class (.ts file). eval() is not an option.
I have tried using window[functionName] , but it fails, guess because window context is outside the class
Any idea?
If your function is defined in a seperate class or service import it via the constructor and invoke the function. Like this
constructor(private serv: FunctionService){
serv.your_function();
}
Call it inside the constructor or where ever it is appropriate depending on the context. Hope this sounds meaningful.