The barcode is used mostly in all products, to ease the work of billing. If you have the barcode, there is no need remember the price, the product name, and specification. The barcode has a unique number which is linked to the database containing corresponding product information. This is not only applied to products but also to services.

Start Ionic project using.

ionic start barcode blank

Then go to barcode folder.

cd barcode

Then add cordovaBarcodeScanner plugin.

cordova plugin add

(To execute the above command use only Git Bash).

Download ngCordova using

Include ngCordova js file in index.html.

<script type="text/javascript" src="js/ng-cordova.min.js" ></script>

Add controller.

<body ng-app="starter" ng-controller="barctrl" >

Add ngCordova to app.js.

angular.module('starter', ['ionic','ngCordova'])

Create a button inside <ion-content> and when the button is clicked write an action to scan a barcode in app.js.

Add a button inside <ion-content> tag.

<button class="button button-positive" ng-click="scan()" >Scan</button>

Create scan() function inside your controller.




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



     .then(function(barcodeData) {

       // Success! Barcode data is here


     }, function(error) {

       // An error occurred


    // NOTE: encoding not functioning yet


     .encode(BarcodeScanner.Encode.TEXT_TYPE, "")

     .then(function(success) {

       // Success!


     }, function(error) {

       // An error occurred


 }, false);



That’s all. To generate apk.

ionic platform add android

ionic build android

Tested Device

Samsung J7 Android Lolipop