Skip to Content
avatar image
Former Member

How can i call multiple js file functions inside my controller?

#######below is my utility.js (not controller) file #######
sap.ui.define(

], function() {

"use strict";

return {

test:function() {

debugger; }

}; });

Now i wanted to call test method inside my controller.

By doing sap.ui.controller("namespace.Controllername").method(); i can able to access controller but not js file.

Looking forward to extend my js file and/or to call js file as above!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Apr 28, 2017 at 08:17 PM

    you'll have to inject the js files in your controller.

    sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "path/to/file1",
    "path/to/file2"
    ], function(Controller, File1, File2){
    
    return Controller.extend("MyController",{
    
       test : function(){
    
          File1.methodName() // invoke method in file1.js
     
          File2.methodName() //invoke method in file2.js
    
       }
    
    }
    
    });
    Add comment
    10|10000 characters needed characters exceeded