Solution 1:
function getText(){
if(someVariable==someValue){
return 'text1';
} else{
return 'text2';
}
};
Ext.define('DemoApp.view.Main', {
//Some code here
...
items: [{
xtype: 'label',
text: getText()
}]
});
In this case, if you are writing the main definition as a separate file, getText function will become global function.
Solution 2:
Ext.define('DemoApp.view.Main', {
//Some code here
...
initComponent: function(){
function getText(){
if(someVariable==someValue){
return 'text1';
} else{
return 'text2';
}
};
this.items = [{
xtype: 'label',
text: getText()
}];
this.callParent(arguments);
}
});
textfield? Likeitems[0].text = 'Test'. As it stands, it seems that you are just settingtextto be a function and not executing that function.