Try this:
if (cordova.plugins.barcodeScanner) {
cordova.plugins.barcodeScanner.scan((imageData) => {
this.nav.push(ItemDetailsPage, {
itemid: imageData.text
}
)
}, (error) => {
alert("An error happened -> " + error);
});
}
I've added some braces around your fat arrow function, and also changed the if condition since it would make more sense to check for the existence of the barcode scanner object. Also, since you are using fat arrow functions, there is no need to create a reference to 'this' because it will use the parents scope anyway.