cordova-plugin-qrscanner icon indicating copy to clipboard operation
cordova-plugin-qrscanner copied to clipboard

QRScanner - After scan router navigate dosen't work

Open Bartoszkolodziejczak opened this issue 6 years ago • 2 comments

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

Bartoszkolodziejczak avatar Nov 18 '18 15:11 Bartoszkolodziejczak

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

sanek-mizin avatar Dec 13 '18 14:12 sanek-mizin

thank you, is worked

perry1100 avatar Aug 30 '23 03:08 perry1100