I’m creating my own “library” because I want to keep my code DRY. The idea is just to extend SimpleController and send it a name so it could generically load stores and views which are already created but in my console I’m getting a message that the nameOfController is undefined.
1.) In this example, why is nameOfController undefined?
2.) I know how to extend SimpleController but when is the right time to initialize nameOfController? In the init() function? Is there some function wich is executed even before loading stores: [] and views: []?
Ext.define('MyApp.controller.SimpleController', {
extend: 'Ext.app.Controller',
nameOfController: "",
stores: ['MyApp.store.' + this.nameOfController],
views: ['MyApp.view.' + this.nameOfController + '.Index']
EDIT: (example of extending)
Ext.define('MyApp.controller.Users', {
extend: 'MyApp.controller.SimpleController',
nameOfController: "Users" //I want to this nameOfController
//changes the one in superclass
});
You can define constructor for controller. Example: