Firstly, apologies if this is a bit of a newbie question. I’m fairly familiar with Angular but have never used Ionic before (though I did use Phone gap about 18 months ago). So My knowledge isn’t the best.
Basically I’m trying to throw together a proof of concept that includes a barcode scanner. I have a button within a ionic modal. This button has
ng-click="scan()"
Then in my controller I have:
$scope.scan = function () {
cordova.plugins.barcodeScanner.scan(
function (result) {
var s = "Result: " + result.text + "<br/>" +
"Format: " + result.format + "<br/>" +
"Cancelled: " + result.cancelled;
//resultDiv.innerHTML = s;
console.log("Success");
},
function (error) {
alert("Scanning failed: " + error);
}
);
};
All I need at this stage is for the scanner to pop up and me to be able to scan a barcode and write the details to console. Very simple, but I am obviously missing something as I can’t get it to work. I’ve tried injecting cordova into my controllers deps with no success.
What do I need to do to enable/include the plugin and then use it in my controllers?
Managed to solve this - for some reason when I cloned the barcode scanner repo it missed half the files and create a load of duplicate folders… Deleted these and recloned and it works fine. Thanks for your help