Skip to content

Instantly share code, notes, and snippets.

@chalettu
Created June 3, 2015 20:27
Show Gist options
  • Save chalettu/ab1d9ec881778b0cc31e to your computer and use it in GitHub Desktop.
Save chalettu/ab1d9ec881778b0cc31e to your computer and use it in GitHub Desktop.
Barcode Scanner Sample
$scope.currentlyScanning=false;
$scope.loadScanner=function(){
// alert("loading barcode scanner");
if ($scope.currentlyScanning===true){
return;
}
else
{
$scope.currentlyScanning=true;
}
$cordovaBarcodeScanner
.scan()
.then(function(barcodeData) {
$scope.currentlyScanning=false;
$scope.barcodeData=barcodeData;
if ($scope.barcodeData.cancelled===0 && $scope.barcodeData.text!=""){
var product_id=$scope.barcodeData.text;
$state.go("product",{product_id:product_id});
}
// Success! Barcode data is here
}, function(error) {
// An error occurred
$scope.currentlyScanning=false;
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment