Provide tool to detect bar code scan and pick back the value of the bar code
You can clone this project or directly use bower:
bower install --save angular-bar-code-scanner
In order to use the bar code scan, you will need to include the lib:
// In your app.js angular.module('myApp', ['angular-bar-code-scanner']);
Then include the directive "barCodeScanner" in your template on element (we don't really care about the type of element):
<body data-bar-code-scanner>
...
</body>
Now your application is able to detect scan. Just catch the scan event by listen the event:
angular.module('myApp').controller('MyController', function($scope){
$scope.$on('bar-code-scan-event',function(event, parameters){
console.info('Scan detected, bar code is : ' , parameters.barCodeValue);
}
});
You can configure two type of things:
- The event name broadcast by directive
- The number of char we use to consider that its a scan
Example :
``` angular.module('myApp').config(function(BarCodeScannerConfigProvider) { // Now you will need to listen event 'scan' BarCodeScannerConfigProvider.setBroadcastEventName('scan'); // Now you consider that bar code are make of 20 numerical char BarCodeScannerConfigProvider.setNumberOfCharOfBarCode(20); }) ```