Skip to Content
0
Former Member
Aug 14, 2016 at 01:49 AM

How to define global variables in new UI5 project

2980 Views

What is the suggested way to define global variable in new UI5 webide project.

sap.ui.define([ 
"sap/ui/core/mvc/Controller" 
], function(Controller) { 
"use strict";
return Controller.extend("test.controller.View1", 
{
oView: null, 
onInit: function() { 
oView = this.getView(); 
},
});
}); 

When defined as above , i am facing an error that oView is not defined.

I have another ui5 project where controller was defined in a different way and working fine.

sap.ui.controller("test.view.main", 
{
oView: null, 
onInit: function() { 
oView = this.getView(); 
},

Why does the way controllers defined for each version. Its getting tough to catch up the pace the changes are being made to project definitions at regular intervals.