Search code examples
sapui5amd

Required module missing methods


Is it a bug from UI5 (1.60.2) or I am doing something wrong here?

onSelectPreferredTreatment: function(event) {
  // ...
  const oDialog = new Dialog({/*...*/});
  oDialog.open();
},

VM77446:1 Uncaught TypeError: oDialog.open is not a function
at eval (eval at onSelectPreferredTreatment (Preview.controller.js?eval:NaN), :1:9)
at f.onSelectPreferredTreatment (Preview.controller.js?eval:552)

Full structure of oDialog


Solution

  • Check the dependency list in your controller. The order of the required modules should reflect the order of available parameters of the callback function exactly.

    sap.ui.define([
      "sap/ui/core/mvc/Controller", // 1st
      "sap/m/Dialog", // 2nd
      // ...
    ], function(Controller/*1st*/, Dialog/*2nd, ...*/) {
      // ...
    });
    

    You might also have required some modules twice, similar to https://stackoverflow.com/a/55289688/5846045