Closed crispconcepts closed 8 years ago
Nvm. I will use a simpler solution since this one seems unsupported. For those curious..
html
<body ng-view ng-keypress="keyPressed($event)"></body>
controller
var keys = "";
var barcodeIsDone = false;
$scope.keypressed = function(event){
$timeout(function(){
if(event.key == "Enter"){
var barcodeIsDone = true;
}else{
keys = keys + event.key;
var barcodeIsDone = false;
}
if(barcodeIsDone){
$scope.scanner_input = keys;
barcodeIsDone = false;
keys = "";
}
});
};
$scope.$watch('scanner_input', function(value) {
.......
.......
$timeout(function(){
$scope.scanner_input = "";
}, 500);
});
Thanks you @ljacobs-sml. I had the same conflict but this helped me.
I'm not sure this is the fault of the bookmarklet itself, but it was involved in producing of the error.
I am including the barcode js file after angular js file, and before app/ctrl js files on index.html
I include it as a dependency..
I add it to template/view html file..
<barcode-listener on-scan="handleScan" prefix="" scan-duration="500"></barcode-listener>
I then click the bookmark and I get the following error in console..
Is it failing to inject it to the document for some reason?
Also, do you have an example implementation of an onScan event/function in the controller? There isn't one in the documentation or anything explaining how to handle the barcode data once it reaches controller. Would it be something like
$scope.handleScan = function(barcode){console.log(barcode);}
?