How can we define a constructor in a class in ExtJS?
The constructors are special method that are executed when a class is instantiated. You can use constructor to prepare the object in any way required. For example, to set up the default property values.
eg:
Ext.define('Test.Emp', {
config: {
name: 'Raja',
gender: 'Male'
},
constructor: function(config){
// initialize our config object
this.initConfig(config);
},
getDetails: function(){
alert('My name is ' + this.name);
}
});
var honey = Ext.create("Test.Emp",{
name: 'Mary',
gender: 'Female'
});
Comments
Post a Comment