Business Console 10.7 | webMethods Business Console Documentation | Developing Gadgets for Business Console | Programming Gadgets | Invoking JavaScript Functions with Same Name in Different Libraries
 
Invoking JavaScript Functions with Same Name in Different Libraries
For AngularJS gadget, JavaScript functions must be specifically defined in either controller.js or as AngularJS services, which are singleton objects or single use classes. Duplicate functions inside different services can be easily invoked by using the service injections. For non-AngularJS based gadgets, because the functions can be directly defined on the Window object, functions with same might result in conflicts.
To resolve conflict between similarly named functions, it is recommended that you encapsulate functions inside a binding function, and then use the binding functions to invoke the functions inside.
For example,
var GadgetOne_Controller = function($scope) {

this.userDefinedFunctionOne = function() {
console.log("from userDefinedFunctionOne function of mygadget");
}


this.userDefinedFunctionTwo = function() {
console.log("from userDefinedFunctionTwo function of mygadget"); }
}
}

var gadgetOne_Controller= new GadgetOne_Controller(); // NOTE THE
DIFFERENT CASES
In this case, you can invoke the gadgetOne_Controller.userDefinedFunctionOne() from your view file.