Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Angular 16 framework support for this library #902

Open
saifk9 opened this issue Mar 15, 2024 · 4 comments
Open

[Feature Request] Angular 16 framework support for this library #902

saifk9 opened this issue Mar 15, 2024 · 4 comments

Comments

@saifk9
Copy link

saifk9 commented Mar 15, 2024

Is your feature request related to a problem? Please describe.
I'm encountering difficulties integrating the html5-qrcode library into my Angular 16 project due to a lack of clear syntax and implementation methods.

Describe the solution you'd like
I require clear guidance and documentation on the syntax and proper implementation methods for integrating the html5-qrcode library into an Angular 16 project. Specifically, I need detailed instructions on how to effectively utilize the library within the Angular environment to scan items from a mobile device and update the quantity.

Describe alternatives you've considered
Given the current challenges, I've explored several alternatives, including:
*Searching for comprehensive tutorials or guides specifically tailored to integrating html5-qrcode with Angular 16.
*Seeking assistance from the Angular community or forums to identify best practices or workarounds for integrating external libraries into Angular 16 projects.
*Exploring alternative QR code scanning libraries with better documentation and support for Angular 16.

Additional context
*Any relevant screenshots or code snippets demonstrating the challenges faced during integration.
*Details about the specific areas where clear syntax and implementation methods are lacking.
*Information on the Angular 16 project environment, including dependencies and configurations.
*Any additional context or specifications that may aid in providing accurate guidance and support.

@saifk9 saifk9 changed the title [Feature Request] One liner for the request [Feature Request] Angular 16 framework support for this library Mar 15, 2024
@ROBERT-MCDOWELL
Copy link

html5-qrcode was never developed to be on angular framework. however you can easily create a PR to satisfy your wishes.

@lazmeister
Copy link

We have implemented this in Angular. Let me know if you still need help with this

@saifk9
Copy link
Author

saifk9 commented May 10, 2024 via email

@lazmeister
Copy link

lazmeister commented May 10, 2024

Hope this helps, npm i html5-qrcode in your angular project,

For your barcode component (giving you bits and pieces but let me know if that helps)


import { Html5Qrcode} from 'html5-qrcode';

  qrResultString: string;

ngOnInit() {
    const html5QrCode = new Html5Qrcode('qr-reader');
    const config = {
      fps: 10,
      qrbox: 300,
      showTorchButtonIfSupported: true,
      rememberLastUsedCamera: true,
      showZoomSliderIfSupported: true,
      useBarCodeDetectorIfSupported: true,
      defaultZoomValueIfSupported: 2};

    const onScanSuccess = (decodedText, decodedResult) => {
      if (!this.qrResultString) {
        // handle the scanned code as you like, for example:
        console.log(`Code matched = ${decodedText}`, decodedResult);
        this.qrResultString = decodedText;
        this.utilitiesService.delay(1000); // this is just a ms delay function
        html5QrCode.stop();
        this.dismissModal(); // our own function to close the modal (we are using Ionic)
      }
    };
    const onScanFailure = (error) => {
    };
    // If you want to prefer back camera
    html5QrCode.start({ facingMode: 'environment' }, config, onScanSuccess, onScanFailure);
  }

HTML:

<div style="width: 100%">
  <div id="qr-reader" class="qr-reader"></div>
</div>

CSS:


.barcodeModal {
  z-index: 1;
}

.qr-reader {
  display: inline-block;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants