Barcode scanner result not being written to Inputs


#1

I have 2 inputs ng-model=‘deviceid’ and ng-model=‘companyid’

I scan a QR code and the results is split to populate both inputs. Here is my code for scanning the QR code:-

function ($scope, $stateParams) {
    
    $scope.scanQR = function (){
        cordova.plugins.barcodeScanner.scan(
            function (result) {
            //console.log(result.text);
            var TagResponse = result.text;
             var config = TagResponse.indexOf("Config:");
            var http = TagResponse.indexOf("itms");
            if (TagResponse !== '') {
            if (config === 0) {
            var ConfigVals = TagResponse.split(':');
            $scope.result = {};
            $scope.result = {deviceid: ConfigVals[1]};
            $scope.result = {companyid: ConfigVals[2]};
            }
            }                              
            });
    return false;
}
}

deviceid and companyid are not written back to the inputs until I try to scan again and then the text is written to the input boxes.

Any thoughts as to why the text isn’t written out immediately after scanning the QR code.

The QR code generates the text Config:123456:mycompany.