I need to have a set of Global Variables in a class, and need to access it from other classes. I have the following problems, can someone help me ?
1.) What type of class should i add ? is it a View ? Can someone show an example ?
2.) How can i set values to the variables in this class from my Controller and View classes ?
3.) How can i retrieve the values of these variables from this class (global variable class) ?
note: I know how to add it to the app.js and write/read from other classes. But i want to have a separate class for global variables.
Add them as statics in a new class:
Ext.define('MyApp.util.Utilities', {
statics: {
myGlobal: 1
}
});
At which point you load the class up and from anywhere in the app you can write MyApp.util.Utilities.myGlobal = 5.
This is an extension of my answer here to a similar problem: Where should I define global functions in ExtJS 4 MVC?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With