question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ionic/Angular not read

See original GitHub issue

I have a Ionic 5 and Angular 12 App.

html5QrcodeScanner is displayed correctly, but the onScanSuccess callback is never called. I can’t read qr codes or barcodes of any kind.

I’m opening a modal window with this html:

<div id="qr-reader" style="display: inline-block;"></div>

In the typescript part, I have this:

import { Html5QrcodeScanner } from 'html5-qrcode';

html5QrcodeScanner = null;

ngOnInit() {
    this.html5QrcodeScanner = new Html5QrcodeScanner('qr-reader', { fps: 10, qrbox: { width: 250, height: 250 }}, false);
    this.html5QrcodeScanner.render(this.onScanSuccess);
}

onScanSuccess(decodedText, decodedResult) {
    console.log(`MATCH = ${decodedText}`, decodedResult);
}

I can see any error in the console.

Any help will be appreciated.

Thanks scanner

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
leocharruacommented, Nov 6, 2021

Sorry, I found the problem. In the real code, in the callback function (onScanSuccess), I used a global var to assign the decoded text:

this.value = decodedText;

In a callback function this line breaks the run without any error or warning.

The way to solve this, is assign the callback function in this way:

this.html5QrcodeScanner.render((text, result) => this.onScanSuccess(text, result));

I think you can use this code snippet like recipe for Angular (and Ionic too).

Thanks

0reactions
leocharruacommented, Nov 22, 2021

@troyanskiy : “html5-qrcode”: “^2.1.2”,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read property 'target' of undefined - Ionic Angular
event is undefined in fileChanged because it's not being passed when the event is raised. You need to pass the event payload in...
Read more >
Error ionic 5 Angular 10 TypeError: Cannot read properties of ...
Hi comunity, the solution was to change the <ion-router-outlet> tag to <ion-nav> that was inside the <ion-split-pane> tag. This would overwrite ...
Read more >
Environment Variables in Angular / Ionic | by Adnane Lamghari
Solution 1: Create a environment.ts file for each environment · Create environment.preprod.ts file in src/environment folder · In your angular.json file add the ......
Read more >
Authentication in Ionic Angular with Supabase
If you are not yet familiar with Ionic you can check out the Ionic Quickstart guide of the Ionic Academy or check out...
Read more >
Chapter 4, Just Enough Angular and TypeScript - O'Reilly
Since the beginning, the Ionic Framework has been built on the Angular framework. ... designed to read physics papers and not to build...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found