Last active
February 7, 2022 02:12
-
-
Save AlexSwensen/725ae0b32873612d2db4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$scope.scanCode = function () { // Scan code | |
$ionicLoading.show({ | |
template: '<ion-spinner></ion-spinner>' | |
}); | |
console.log("scanCode run"); | |
if ($scope.currentlyScanning === true) { | |
$ionicLoading.hide(); | |
return; | |
} | |
else if (ionic.Platform.platforms.indexOf("browser") !== -1) { | |
setTimeout(function () { | |
$ionicLoading.hide(); | |
$cordovaDialogs.alert("QR Code scanner not available in development browser."); | |
}, 1000); | |
return; | |
} | |
else { | |
$scope.currentlyScanning = true; | |
} | |
$cordovaBarcodeScanner | |
.scan() | |
.then(function (barcodeData) { | |
//$cordovaDialogs.alert(barcodeData.text, 'barcodeData', 'OK'); | |
$ionicLoading.hide(); | |
$scope.currentlyScanning = false; | |
$scope.launchBrowser(barcodeData.text, '_blank'); // pass data.text (the url in this case) to a function that launches the browser | |
}, function (error) { | |
$ionicLoading.hide(); | |
$scope.currentlyScanning = false; | |
$cordovaDialogs.alert(error, 'barcode Error', 'OK'); | |
}); | |
}; // end scanCode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works like a charm! TY