zxing-js / ngx-scanner

Angular QR code, Barcode, DataMatrix, scanner component using ZXing.
https://zxing-js.github.io/ngx-scanner/
MIT License
640 stars 228 forks source link

handleQrCodeResult Not Being Called on Scan Success #124

Closed bm2112 closed 6 years ago

bm2112 commented 6 years ago

Describe the bug I'm integrating this website into an ASP.NET project I am working on and I am trying to redirect to another url when a scan is successful. I added a couple lines of code to the handleQrCodeResult method, and I have a breakpoint there in VS 2017. However, even when the scan is successful the method is not called. I haven't changed any of the code in app.component.html. I am depending on the (scanSuccess) method shown here.

<zxing-scanner #scanner start="true" [device]="currentDevice" (scanSuccess)="handleQrCodeResult($event)" formats="['CODE_39', 'CODE_128', 'QR_CODE']">

Expected behavior I expected it to execute the handleQrCodeResult function in app.component.ts.

Desktop (please complete the following information): IIS Express (debugging in Visual Studio 2017)

odahcam commented 6 years ago

Well, there's no way I know if you're doing it right you know? That's why we ask for a StackBlitz like example, so we can debug your code and find out what's wrong. Can you provide one?

bm2112 commented 6 years ago

This is my first time working with AngularJS but when I posted this I was just trying to change the code in app.component.ts and then run the application. I realized that I needed to rebuild the bundles with the new code, so I did an "ng build --prod", but now I am getting this error when running the site from IIS: "ERROR TypeError: "e.map is not a function".

I have the main bundle and the app.component.ts file in this StackBlitz if you'd like to look at it: https://stackblitz.com/edit/angular-fewsox

All I want to do with the original code you have, is add the line: window.location.href = 'http://localhost:58430/docs/DBConnect.aspx?result=' + resultString; in the handleQrCodeResult function. What is the right way to do this?

Thanks

bm2112 commented 6 years ago

I figured it out on my own. I just added that line in the main bundle after I did a ctrl-F for "handleQrCodeResult" since I couldn't get it to build without errors.

odahcam commented 6 years ago

I see, did you install @zxing/ngx-scanner throught npm?

bm2112 commented 6 years ago

Yes, I did. I'm currently just editing the main bundle to suit my application's needs right now, and I realize there has to be a much easier way.

odahcam commented 6 years ago

Sorry, I'm a little confuded here. 😅

Our first time with Angular is always a little mess, so don't worry about any strange thing happening.

You can still get in touch with us for solving errors, we help as much as we can, feel free to join our Gitter chat.

Cya.

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.