Skip to content

carlholmberg/angular-bar-code-scanner

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

angular-bar-code-scanner

Provide tool to detect bar code scan and pick back the value of the bar code


Installation

You can clone this project or directly use bower:

bower install --save angular-bar-code-scanner


Basic Usage

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);
    }
});

Configuration

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); }) ```

About

Provide tool to detect bar code scan and pick back the value of the bar code

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%