Showing results for 
Search instead for 
Did you mean: 

how to set global variable in ui5 controller

Former Member
0 Kudos

I am learning ui5 via webide and have to assign a global variable that can be used in any controller. I tried assigning a new variable

'var testglobalvariable=null;' in the controller as below, but ide throws an error everytime. How to assign ?

var testglobalvariable=null;



], function(Controller) {

  "use strict";

  return Controller.extend("testapp.controller.View1", {



Accepted Solutions (0)

Answers (1)

Answers (1)

Active Contributor
0 Kudos

you can add it to your model... and then you can access this variable from the model through your application

get a handle of your model... then... you can set it via..

model.setProperty('/varName', value)

and to retrieve it


Former Member
0 Kudos

thanks for suggestion , but i cannot use it via model everytime. as i have other functions which accesses it and plays around this variable before assigning back to view/model again.