# Noob: barcode scanner issue ngCordova and Ionic

**URL:** <https://forum.ionicframework.com/t/noob-barcode-scanner-issue-ngcordova-and-ionic/72841>\
**Category:** cordova\
**Created:** [December 10, 2016, 1:08pm UTC](https://forum.ionicframework.com/t/noob-barcode-scanner-issue-ngcordova-and-ionic/72841 "2016-12-10T13:08:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rtuin](https://avatars.discourse-cdn.com/v4/letter/r/f17d59/32.png) [@rtuin](https://forum.ionicframework.com/u/rtuin)\
**Post date:** [December 10, 2016, 1:08pm UTC](https://forum.ionicframework.com/t/noob-barcode-scanner-issue-ngcordova-and-ionic/72841/1 "2016-12-10T13:08:36Z")

</div>

Hello,  
I am stuck getting the barcode scanner plugin to work.  
USB debugging my native Android I get the following result:

> \ionic.bundle.js:26799 TypeError: Cannot read property ‘scan’ of undefined  
> at ChildScope.$scope.scanBarcode (controllers.js:11)  
> at fn (eval at compile (ionic.bundle.js:27643), :4:224)

I have installed the latest barcode plugin:

> bleep# cordova plugin add [GitHub - Telerik-Verified-Plugins/BarcodeScanner: Available on the Verified Plugins Marketplace](https://github.com/Telerik-Verified-Plugins/BarcodeScanner)

> bleep# ionic plugin ls  
> com.phonegap.plugins.barcodescanner 6.0.4 “BarcodeScanner”

in index.html I have:

> ```
> <script src="lib/ngCordova/dist/ng-cordova.min.js"></script>
> <script src="cordova.js"></script>
> 
> ```

and the controller is:  
angular.module(‘app.controllers’, )

.controller(‘scanModeCtrl’, [‘$scope’, ‘$stateParams’,‘$ionicPopup’, function ($scope, $stateParams,$ionicPopup,  
$cordovaBarcodeScanner) {  
$scope.selected = undefined;  
$scope.location = Location;

```
$scope.data = {}
$scope.scanBarcode = function() {
        console.log('scanning');

        $cordovaBarcodeScanner.scan().then(function(barcodeData) {
            alert(JSON.stingify(barcodeData));
          }, function(error) {
            console.log("An error happened ->" + error);
          });

```

I am unable to find why this is not working. I an quite new to Ionic, but had the barcode plugin working just fine in a jquery phonegap application, so I do know what to expect.

Any help is welcome, for this is locking any progress for over 2 days now and slowly driving me crazy.

---

<div class="post-metadata">

**Author:** ![rtuin](https://avatars.discourse-cdn.com/v4/letter/r/f17d59/32.png) [@rtuin](https://forum.ionicframework.com/u/rtuin)\
**Post date:** [December 11, 2016, 10:17am UTC](https://forum.ionicframework.com/t/noob-barcode-scanner-issue-ngcordova-and-ionic/72841/2 "2016-12-11T10:17:31Z")

</div>

Found the solution,  
forgot to add $cordovaBarcodeScanner

.controller(‘scanModeCtrl’, [’$scope’, ‘$stateParams’,’$ionicPopup’, **’$cordovaBarcodeScanner’,**  
function ($scope, $stateParams,$ionicPopup,$cordovaBarcodeScanner) {
