我尝试了一些不同的方法,但无法将数据从 Controller 传递到 View (到容器内的组件)。
这里我有 View ServisDetail.js :
Ext.define('Asistan.view.ServisDetail', {
extend: 'Ext.Container',
xtype: 'servisDetail',
config: {
layout: 'fit',
items : [
{
xclass : 'Asistan.view.ServisToolbar'
},
{
// "data: {}" is needed to work. I try to pass data from controller to here
xtype: 'component',
tpl: Ext.create('Ext.XTemplate','{URUN_CIHAZ_ADI} jkjk')
}
]
}
});
这是我的 Controller Servis.js我认为认为它应该有效。但它不传递数据:
Ext.define('Asistan.controller.Servis', {
extend: 'Ext.app.Controller',
config: {
refs: {
servis: 'servisNavigationView servisContainer list',
},
control: {
servis: {
itemdoubletap: 'showServis'
}
}
},
showServis: function(item, index, e, eOpts) {
this.servis = Ext.widget('servisDetail');
this.servis.config.items[1].data = eOpts.data; // <- Here! It doesn't work. console.log shows that the data is there but in the browser the data doesn't show up.
console.log(this.servis.config.items[1].data); // I can see my data here, right before the push
item.up('servisNavigationView').push(this.servis);
}
});
我缺少什么?
最佳答案
尝试使用
showServis: function(item, index, e, eOpts) {
this.servis = Ext.widget('servisDetail');
this.servis.setData(eOpts.data); // setData applies the data to the container template.
item.up('servisNavigationView').push(this.servis);
}
关于javascript - 我无法将数据从 Controller 传递到 Sencha Touch 2.4 中的 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31200809/