DEV Community

Lê Hồng Long
Lê Hồng Long

Posted on

AMD Syntax in SAP UI5

1. Syntax

sap.ui.define([
     , function( ) {
    });
});
Enter fullscreen mode Exit fullscreen mode

Example

sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "sap/m/MessageToast"
], function(Controller, MessageToast) {
    "use strict";
    return Controller.extend("ui5.walkthrough.controller.App", {
        onShowHello: function() {
            MessageToast.show("Hello World");
        }
    });
});
Enter fullscreen mode Exit fullscreen mode

2. Explain
Write in Webapp/index.js
sap.ui.define is function to declare a new module in SAP UI5
[] : array store: path of module dependencies, example: "sap/ui/core/mvc/Controller"
function( ) { }); module name is parameter of function, so called callback function.

3. Debugging
-Add breakpoint in F12(devtools)
-Add line: debugger;

Top comments (0)