Thank you for your feedback.
Form temporarily unavailable. Please try again or contact to submit your comments.
  • Madrid
  • London
  • Kingston
  • Jakarta
  • Istanbul
  • Helsinki
  • Geneva
  • Store

Widget Client Script

Log in to subscribe to topics and get notified when content changes.

Widget Client Script

Use the Client Script to handle all the client-side logic and template binding for your widget.

This information is for pro code users. Only make changes to client scripts if you have a firm understanding of AngularJS.

Every widget is an Angular directive; you can use the Client Script to define the controller for that directive. The Client Script is the controller already linked to the widget. For example, the stock widget uses the following client script:

function() {    
    var c = this;
    c.update = function() { = false;
        c.server.get({}).then(function(r) {            
Table 1. Client Script properties
Property Description
this.server.get([Object]) Calls the server and sends custom input. Returns Promise.
this.server.update() Calls the server and is automatically send to server side. Returns Promise.
this.server.refresh() Calls the server and automatically replaces the current options and data from the server response. Returns Promise.

A promise represents the eventual result of an asynchronous operation. Promises are objects or functions that usually contain a then method, which subscribes to this specification. For more information on promises, see or the AngularJS documentation site.

Because catalog client scripts need to be compatible with the mobile API, some already existing catalog client scripts may not work in Service Portal.