scan() {
var me = this;
if (window.cordova) {
cordova.plugins.barcodeScanner.scan((imageData) =>
me.nav.push(ItemDetailsPage, {
itemid: imageData.text
}
)
, (error) =>
alert("An error happened -> " + error)
);
}
}
}
The Idea was to read the barcode and send the value to another page to show some details about the item.
Trying it on my Nexus 5 I don’t see any errors on the adb.
Are you sure the “if (window.cordova)” line is true?
The community really needs to lean on the Ionic team to put together a tutorial on how to include cordova plugins that don’t already have native Ionic2 support. I’ve been scouring the internet to figure this out, and am still forced to use Ionic v1 because of this limitation.
Hi,
The line is true because I can do the scanning and if i just do an alert with the imagedata.text it works.
I just can’t get the navigation to change.
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.
I’m developing with this plugin also. It seems that the view does not update at all. I wish I could help but the only thing I could come up with is doing everything inside the same view you started in, even then nothing updates automatically. I wonder if there is a similar way to force the view to update like in angular 1 $scope.apply()