Ionic/Angular not read
See original GitHub issueI 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
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, I found the problem. In the real code, in the callback function (onScanSuccess), I used a global var to assign the decoded text:
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:
I think you can use this code snippet like recipe for Angular (and Ionic too).
Thanks
@troyanskiy : “html5-qrcode”: “^2.1.2”,