如何获得视图的控制器
var c = Alloy.createController('win', activeTab);
c = c.getView();
Wins.push(c);
在控制器赢我有功能
exports.fun = function() {
};
从控制器获得胜利之后,该视图如何从视图中调用此函数,我需要控制器来调用该函数
for ( i = 0; i < Wins.length; i++) {
Wins[i].fun();
}
Wins [i]是一个视图如何获取该视图的控制器,以便可以调用函数
fun()
最佳答案
不要推窗户,推控制器
// this is a bad name for a controller...
var controller = Alloy.createController('win', activeTab);
var view = controller.getView();
// save the controller to a list of global controllers
Alloy.Globals.Controllers = Alloy.Globals.Controllers || {};
Alloy.Globals.Controllers['aController'] = controller;
// loop through all controller and execute func if it exists
for ( var i in Alloy.Globals.Controllers) {
Alloy.Globals.Controllers[i].fun && Alloy.Globals.Controllers[i].fun();
}
关于javascript - 从getView()调用 Controller ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17215719/