Help with QR Code reader in Cordova

2

I'm trying to make the app (cordova + onsen) read a QR code and when reading open the link contained in the QR, but instead of opening the link it tries to open a page in the root of the application (file: // android_asset / www / barcode.result).

In the code I just added var ref = window.open('barcode.result', '_blank'); the rest is working normally, it just does not open the link contained in the QR.

Follow my barcode controller code:

app.controller('barcodeController', function( $scope ) {
    $scope.barcode = {
        'result': '',
        'format': '',
        'cancelled': ''
    };

    $scope.startScanner = function() {
        cordova.plugins.barcodeScanner.scan(function (result) {
            $scope.$apply(function() {
                $scope.barcode = {
                    'result': result.text,
                    'format': result.format,
                    'cancelled': result.cancelled
                }
                var ref = window.open('barcode.result', '_blank'); //parte acrescentada
            });
        },
        function (error) {
            alert("Scanning failed: " + error);
        }
    )};
});
    
asked by anonymous 13.11.2015 / 01:31

3 answers

1
var ref = window.open(barcode.result, '_blank');

without '' while referencing variable barcode.result

    
13.11.2015 / 12:24
0

I was able to make it work, what was missing was to save the QR result to a variable and then use the result of that variable to open the site.

    
13.11.2015 / 16:48
0

Well, use the terminal, navigate to the folder of your cordova application and install the InAppBrowser plugin:

cordova plugin add org.apache.cordova.inappbrowser

Then in your code when you want to open the system browser use the target _system

window.open('http://google.com', '_system');

or

<a href="http://google.com" target="_system"> abrir browser do sistema </a>
    
13.11.2015 / 17:52