Skip to Content
0
Aug 05, 2015 at 12:21 PM

Uncaught TypeError: Cannot read property '0' of undefined in UI5

585 Views

Dear friends,

I create two button in my view like this: but when I add this press function which created in my controller.js it will have this error :

Uncaught TypeError: Cannot read property '0' of undefined when I remove this press function, the view will run successfully. do I miss something in my code?

My view:

iPanel1.addButton(new sap.ui.commons.Button({text: 'Update',

press: oController.updateheaderdata()

}));

iPanel1.addButton(new sap.ui.commons.Button({text: 'Insert',

press: oController.createheaderdata()

My controller:

sap.ui.controller("demo1.Chart", {

createheaderdata: function(){ //My function code },

updateheaderdata: function(){

//My function code }

});

Best Regards,

Zhang