I have a situation in which there are main functions named as:
Add_<Element_Type>_Page()
where Element_Type is received as a parameter.
I can see two options to handle the invocation of the correct function:
Write a relatively long
switchconstruct covering all possible values ofElement_Type, orUse some existing mechanism/trick (I'm not aware of) through which I can build a string using the received
Element_Typeand invoke a function whose name is contained in that string.
Needless to say, all the functions that can be invoked this way have exactly the same signature as far as parameters is concerned.
Obviously, Option 2 would be the best (easy to maintain and very general as no changes are needed whenever a new type of pages is added).
Is this possible to achieve within AngularJS framework?
Thanks in advance.
$scopeorvm/ctrl?Add_<Element_Type>_Page()and where isElement_Typeneeded in those function?switchconstruct.