cordova-plugin-qrscanner
cordova-plugin-qrscanner copied to clipboard
QRScanner - After scan router navigate dosen't work
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
constructor(private _ngZone: NgZone){ } scan() { ... this._ngZone.run(() => this._router.navigate([''/main/depositor'])); }
thank you, is worked