New! Check out Ionic Native. It's like ngCordova but for ES6 and TypeScript.

$cordovaBarcodeScanner

The Barcode Scanner Plugin opens a camera view and automagically scans a barcode, returning the data back to you.

cordova plugin add https://github.com/phonegap/phonegap-plugin-barcodescanner.git

Methods

scan()

Returns Object with user information, such as id, lastName

encode(type, text)
Param Type Detail
type Constant Encoding type desired (eg: BarcodeScanner.Encode.TEXT_TYPE)
text String String of text to be encoded into desired format

Returns Object with encoded text

Example


module.controller('BarcodeCtrl', function($scope, $cordovaBarcodeScanner) {

  document.addEventListener("deviceready", function () {

    $cordovaBarcodeScanner
      .scan()
      .then(function(barcodeData) {
        // Success! Barcode data is here
      }, function(error) {
        // An error occurred
      });


    // NOTE: encoding not functioning yet
    $cordovaBarcodeScanner
      .encode(BarcodeScanner.Encode.TEXT_TYPE, "http://www.nytimes.com")
      .then(function(success) {
        // Success!
      }, function(error) {
        // An error occurred
      });

  }, false);
});