Update form input after a codebarre scan


#1

Hi all,

i tray to update a form input after code barre scan.
bellow my code. any help?

Thanks

$scope.ScanCode = function() {
  $cordovaBarcodeScanner.scan().then(function(codebare) {
    var elRecharge = document.getElementById(recharge);
    elRecharge.value = codebare.text;
    $scope.operation.recharge = codebare.text;
    $scope.operation.push($scope.operation.recharge);
  }, function(error) {});
};

my form input :

<form name="OperationForm" novalidate ng-submit="sendOpe(operation)">
  <span class="input-label">Field name</span>
  <input type="number" placeholder="34890246870" name="recharge" id="recharge" ng-model="operation.recharge" ng-minlength="1" ng-pattern="matchPattern" value="" required>
  </label>

  <button type="submit" ng-disabled="OperationForm.$invalid" class="button button-dark button-block">
    SEND
  </button>
</form>

#2

hi all, no idea?
thanks


#3

So are you getting any data back after the bar code scan?
Can you log out the data and see if its there?

Also, you shouldn’t be interacting with any DOM elements inside your controller, that should only be touch your scope data.

You could try it like this.

$scope.ScanCode = function() {
  $cordovaBarcodeScanner.scan().then(function(codebare) {
    $scope.inputValue = codebare.text;
    $scope.operation.recharge = codebare.text;
    $scope.operation.push($scope.operation.recharge);
  }, function(error) {});
};
<form name="OperationForm" novalidate ng-submit="sendOpe(operation)">
  <span class="input-label">Field name</span>
  <input type="number" placeholder="34890246870" name="recharge" ng-model="operation.recharge" ng-minlength="1" ng-pattern="matchPattern" value="{{inputValue}}" required>
  </label>

  <button type="submit" ng-disabled="OperationForm.$invalid" class="button button-dark button-block">
    SEND
  </button>
</form>

You could also try to mock it out using a codepen to debug it.


#4

Dear mhartington.
thanks a lot for your reply.
This is the codepen code debug.
http://codepen.io/SamPas/pen/gpREWK.

I tried your solution, but still having problem.
I will apreciate your help!

Best


#5

So do you have an example barcode you could provide for testing?