$ionicLoading not shown with $cordovaBarcodeScanner and $cordovaCamera


#1

Hi,

I’m trying to display a loader while $cordovaBarcodeScanner.scan() is loading (takes between 1s and 5s) but the loader never show up (tested on android, xperia z3 compact).

$ionicLoading.show();
$cordovaBarcodeScanner.scan().then(function (barcodeData) {
    // do stuff on success
}, function (error) {
    // do stuff on error
}).finally(function(){
    $ionicLoading.hide();
});

Digging into $ionicLoading.show() makes me think that $ionicLoading.show() promise gets resolved after the call to $cordovaBarcodeScanner.scan() and that $cordovaBarcodeScanner.scan(), when started does not allow $ionicLoading’s promise to show up.

What I really would like to do is something like below, but I can’t access $ionicLoading promise.

$ionicLoading.show().then(function() {
    $cordovaBarcodeScanner.scan().then(function (barcodeData) {
        // do stuff on success
    }, function (error) {
        // do stuff on error
    }).finally(function(){
        $ionicLoading.hide();
    });
});

Do you have any advice here ?

PS: I have the same issue with $cordovaCamera.