How invoke function by name? Actually I know how invoke function by name, but I can\'t find needed scope. So now I have to use this[\"get\" + widgetName]
You can't invoke private functions via a string variable except via eval()
, and that's generally a bad idea.
However you can trivially create a private object that contains references to those private methods, and then index into that to get the desired function:
function widgetGeneratorService(...) {
var methods = {
func1: func1
...
};
methods['func1']();
}