Currently, I am faced with a scenario where the main functions are named as:
Add_<Element_Type>_Page()
The parameter Element_Type
is passed to these functions.
I have identified two potential methods to handle calling the correct function:
Create an extensive
switch
statement that covers all possible values ofElement_Type
, orUtilize an existing technique or method (that I may not be aware of) to generate a string based on the received
Element_Type
and call a function whose name matches that string.
All functions that can be called in this manner share identical parameter signatures.
Clearly, Option 2 seems more favorable (simpler to maintain and versatile since no modifications are required when introducing new page types).
Can this be implemented within the AngularJS framework?
Thank you in advance.