bitpay / cordova-plugin-qrscanner

A fast, energy efficient, highly-configurable QR code scanner for Cordova apps and the browser.
MIT License
568 stars 773 forks source link

QRScanner - After scan router navigate dosen't work #210

Open Bartoszkolodziejczak opened 5 years ago

Bartoszkolodziejczak commented 5 years ago

Hi, I've got problem with cordova-plugin-qrscanner in Angular project. In my component I scan QR code and if scan is completed I want navigate to another component. Unfortunately its dosen't work correct. This is part of my code

scan() {

     // QRScanner.prepare();
     const that = this;

      QRScanner.show();
     window.document.querySelector('body').classList.remove('transparentBody');
      QRScanner.scan(displayContents);

     function displayContents(err, text) {
      if(err){
        console.log('error', err);
        // an error occurred, or the scan was canceled (error code `6`)
      } else {
        // The scan completed, display the contents of the QR code:
         alert(text);
that._router.navigate(['/main/depositor']);  // here dosen't work
        if (text) {`enter code here`
          QRScanner.destroy((status) => {
            console.log('destroy scanner', status);
         window.document.querySelector('body').classList.add('transparentBody');
that._router.navigate(['/main/depositor']);  // here too dosen't work
          });
        }
      }
    }
  }

Path is correct. I don't know why it's dosen't work. My Angular version is 7.0.6 and cordova 8.1.2. Router change url but view not renderer

sanek-mizin commented 5 years ago

constructor(private _ngZone: NgZone){ } scan() { ... this._ngZone.run(() => this._router.navigate([''/main/depositor'])); }

perry1100 commented 8 months ago

thank you, is worked