Business Console 10.11 | webMethods Business Console Documentation | Developing Gadgets for Business Console | Programming Gadgets | Using Third Party Libraries in Gadgets | Loading External Libraries
 
Loading External Libraries
Use OC Lazy Loader to load external libraries.
Some external JavaScript libraries cannot be used by saving a copy of the JavaScript files in a local system. For example, you cannot store libraries of Google Maps in a local file system and add reference to these libraries in the local folder. Such external libraries must be accessed directly in the view.xhtml file. Referring to these libraries using the <script> tag inside the view.xhtml will not work because the gadgets are AngularJS based, and for the controller to work, the external JavaScript files must be completely loaded. Hence, use the ocLazyLoader provided by the gadget framework to import the external JavaScript files in your view.xhtml file.
Following code snippet shows how to use ocLazyLoader to load external JS libraries.
<div oc-lazy-load="['..js/testModule1.js', '..js/testModule2.js']">

//YOU CAN PROVIDE DIRECT URL TO THE JAVASCRIPT SERVED THROUGH A CDN

//YOUR HTML CODE GOES HERE

</div>
If the link to the JavaScript file does not end with a .js extension, use a js! prefix to your URL as shown below.
<div oc-lazy-load="['js!https://maps.googleapis.com/maps/api/js?key=YOUR
_API_KEY']">
<div class="row">

<map id="map_canvas" style="height: 760px;"></map>

</div>
You can get the API key from Google site: https://developers.google.com/maps/documentation/javascript/get-api-key
You can also use external AngularJS libraries by directly including the module through ocLazyLoad.