我正在构建一个sencha touch应用程序,其中我要求动态加载控制器(以编程方式),而不是通过在app.js中定义它。
答案 0 :(得分:5)
试试这段代码:
Ext.require(controller, function() {//controller - "App.controller.Name"
var c = Ext.create(controller, {application: this}), controllers;
c.init();
c.launch();
/*
The "getController" returns "undefined" for a dynamically loaded controller, so the "controllerInstances" should be updated.
*/
controllers = this.getControllerInstances();
controllers[controller] = c;
this.setControllerInstances(controllers);
}, this.getApplication());