I need to render a template in sencha in mvc pattern , so on InitComponent i have declared some variable but i am unable to acess those variable outside init function . I did following try
Ext.define('casta.view.Intro', {
extend: 'Ext.tab.Panel',
//alias: 'widget.currentDate', //this makes it xtype 'currentDate'
//store: 'CurrentDateStore',
initComponent: function(){
this.planetEarth = { name: "Earth", mass: 1.00 };
this.tpl = new Ext.Template(['<tpl for".">', '<p> {name} </p>', '</tpl>'].join(''));
this.tpl.compile();
this.callParent(arguments);
},
html:this.tpl.apply(this.planetEarth)
});
ERROR
this.tpl is undefined
[Break On This Error]
html:this.tpl.apply(planetEarth)
I’m pretty sure that is not how JavaScript scoping works…
In your example there are 2 ways to do what you would want to do:
or