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