离子条形码扫描仪不返回任何数据

时间:2016-03-29 06:23:46

标签: ionic-framework ngcordova

我正在尝试创建一个简单的,它将从qr代码中读取数据,应用程序运行正常,它可以打开相机并捕获图像,问题是,它无法显示数据/数据是空白的警报如下代码。

这就是我的工作方式

cordova plugin add https://github.com/wildabeast/BarcodeScanner.git

的index.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>

    <!-- cordova script (this will be a 404 during development) -->
    <script src="lib/ng-cordova.min.js"></script>
    <script src="cordova.js"></script>

    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
</head>
<body ng-app="starter">

    <ion-pane>
    <ion-header-bar class="bar-stable">
        <h1 class="title">Ionic Blank Starter</h1>
    </ion-header-bar>
    <ion-content>
        <div class="card">
           <div class="item" ng-controller="ScanCtrl">
               <button class="button button-block button-positive" ng-click="scanBarcode()">
                   <i class="icon ion-qr-scanner"></i>
                   Scan With Scope
               </button>
           </div>
        </div>
    </ion-content>
    </ion-pane>
</body>
</html>

app.js

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

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

      // Don't remove this line unless you know what you are doing. It stops the viewport
      // from snapping when text inputs are focused. Ionic handles this internally for
      // a much nicer keyboard experience.
      cordova.plugins.Keyboard.disableScroll(true);
    }
    if(window.StatusBar) {
       StatusBar.styleDefault();
    }
  });
})

controllers.js

angular.module('starter.controllers', [])

.controller('ScanCtrl', function($scope, $cordovaBarcodeScanner){
 $scope.scanBarcode = function(){
    $cordovaBarcodeScanner.scan().then(function(imgData){
      alert(imgData.text);
    },function(error){
      alert("Error");
    }
    );
  }
});

任何帮助都会非常感激。

0 个答案:

没有答案