webMethods Business Console Documentation 10.5 | webMethods Business Console Documentation | Developing Gadgets for Business Console | Introduction to Business Console | Understanding Business Console Gadget Development | Adding Functions to a Gadget Controller (controller.js)
 
Adding Functions to a Gadget Controller (controller.js)
After you define the user interface for the gadget, add the business logic for the AngularJS based gadgets in the controller.js file.
* To define the business logic for an AngularJS based gadget
1. Navigate to one of the following application project:
a. Portlet Application Project
b. Web Application Project
c. Gadget Application Project
2. Navigate to Gadget_root_directory > Gadget_name > scripts
3. Open controller.js for edit and specify the client-side business logic for the gadget.
Codeblock
Description
URLS
This section is for specifying a JavaScript array of RESTful service URLs for the gadget. You must provide relative URLs. Server details can be provided at runtime.
init
Constructor block which initializes the core services with the $scope object, including config (gadget configuration object), restClient (AngularJS based service to invoke the RESTful services ), eventBus (AngularJS based object to pass events to the listening controllers and also receive events fired from other controllers), and URLS (the URL object mentioned in the URL section).
defineScope
This section allows you to define the JavaScript functions to be added to AngularJS $scope object. These functions can be invoked from any place where there is access to the controller's $scope object, even from view.xhtml by using appropriate AngularJS directives such as data-ng-click.
defineListeners
This section is for attaching the listeners to the AngularJS eventBus object.
_handleEvents
This section is for the event handling functions for every event handler.
destroy
This section gets invoked on controller unload. Use this to clean up any used object including event registration.

Copyright © 2014-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.