【发布时间】:2015-08-03 09:56:50
【问题描述】:
我在我的应用程序中使用了Extjs-6 中的MVVM architecture。我的控制器如下(注意extend: 'Ext.app.Controller'):
Ext.define('App.controller.gt.Point', {
extend: 'Ext.app.Controller',
myProp: {
x: 'x',
y: 'y'
},
init: function()
{
...
},
activateDrawing: function()
{
...
// I want to send myProp to 'App.view.gt.Point' view and
// it(myProp) use binding
var pointWin = Ext.create('App.view.gt.Point', {});
}
});
如果调用activateDrawing,控制器会显示一个窗口(@987654326@ 视图)。这个窗口类如下:
Ext.define('App.view.gt.Point', {
extend: 'Ext.window.Window',
...
controller: 'gt-point',
viewModel: 'gt-point',
items: [{
xtype: 'form',
items: [{
xtype: 'numberfield',
fieldLabel: 'X',
/*
* I want to bind the numberfield with myProp.x
*/
bind: '{myProp.x}',
}, {
xtype: 'numberfield',
fieldLabel: 'Y',
/*
* I want to bind the numberfield with myProp.y
*/
bind: '{myProp.y}',
}]
}],
buttons: [{text: 'OK', action: 'OK', handler: 'onOk'}],
...
});
如果数字字段x 和y 被更改,我想自动更改myProb.x 和myProb.y。这个问题如何实现?
【问题讨论】:
标签: extjs mvvm data-binding extjs6 extjs6-classic