Skip to Content
0

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

Apr 28, 2017 at 01:34 PM

70

avatar image
Former Member

#######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!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

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

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

   }

}

});
Share
10 |10000 characters needed characters left characters exceeded