Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 
According to my understanding, module and controller is different.

1. Controller

Controller is used in view, handling the event triggered in view. The most explicate feature is to extend "sap/ui/core/mvc/Controller".

Like this:
], function (Controller) {
"use strict";
return Controller.extend("sap.ui.demo.walkthrough.controller.App", {
onShowHello : function () {
// show a native JavaScript alert
alert("Hello World");

Step 5: Controllers - Documentation - Demo Kit - SAPUI5 SDK (


2. Module

Firstly, module is a normal principle for javascript. You can see this toturial:

2.1 Usage

  • Clean your code by module.

  • Use module in your fragment. For fragment, you can assign a controller to the fragment when it's loaded. Or you can use import module in fragment and use it like the below code:

<Dialog core:require="{ handler: 'sap/ui/demo/walkthrough/module/HelloDialog'}"
title="Hello {/recipient/name}">
<Button text="Button in Dialog"

In some application generated by Fiori Element, it will be convenient to use the module in fragment. Since the controller and view are invisible.

2.2 Example

  • Use sap.ui.define to define module.

  • Import library.

  • Define private method.

  • Define public method(In the return statement).

], function (MessageToast) {
'use strict';

var privateMethod_1 = function () {"Active private method");

return {
onRaiseMessage: function (oEvent) {

There are some points needs your attention:

  • The public method cannot call another public method, it only can call private method. I am not clear the reason, if you know that, feel free to add comment.

  • If you debug the statement "", you will find that this refers to the view controller not the module. You can use it to operate model or do other things.