完成条形码扫描后将结果分配到文本框

时间:2017-06-07 01:39:00

标签: angularjs ionic-framework barcode-scanner

我正在尝试将条形码扫描的结果分配给角度的文本框,但我无法做到这一点。有人可以帮忙吗?

controller.js

this.formData = {};
this.formData.rawRecipient = "";
$scope.scanBarcode = function() {
            $cordovaBarcodeScanner.scan().then(function(imageData) {
                alert(imageData.text);
                var jsonon = JSON.parse(imageData.text);
                address = JSON.stringify(jsonon.data.addr);
                this.formData.rawRecipient = address;

            }, function(error) {
                alert("An error happened -> " + error);
            });
        };

HTML

<label class="item item-input item-floating-label">
  <span class="input-label">To</span>
     <input type="text" placeholder="{{'FORM_INVOICE_RECIPIENT_PLACEHOLDER' | translate}}" ng-model="$ctrl.formData.rawRecipient"/>
</label>

0 个答案:

没有答案