Once you’ve run the command you can just access the plugin directly, no need to import it or anything like that (you have to be running on a device though). So as it says in the docs:
cordova.plugins.barcodeScanner.scan(
function (result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
},
function (error) {
alert("Scanning failed: " + error);
}
);
that will work anywhere in your code, or if you want to ES6 it up a bit:
cordova.plugins.barcodeScanner.scan(
(result) => {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
},
(error) => {
alert("Scanning failed: " + error);
}
);