1.1.13 • Published 4 years ago

ngx-qr v1.1.13

Weekly downloads
52
License
GPL-3.0-or-later
Repository
github
Last release
4 years ago

ngx-qr

QrScanner will scan for a QRCode from your Web-cam and return its string.

usage

$ npm install --save ngx-qr
// app.module.ts
import { NgQrScannerModule } from 'ngx-qr';
@NgModule({
  // ...
  imports: [
    // ...
    NgQrScannerModule,
  ],
  // ...
})
export class AppModule { }
<!-- app.component.html -->
<qr-scanner (capturedQr)="capturedQr($event)"></qr-scanner>
// app.component.ts
import { Component, OnInit, AfterViewInit } from '@angular/core';
@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.scss'],
})
export class AppComponent implements OnInit, AfterViewInit {

    ngOnInit() {
    }

    capturedQr(result: string) {
        console.log(result);
    }

    ngAfterViewInit() {
    }
}

Translation

Provide the following texts:

export interface QrScannerTexts {
  NotSupportedHTML: string;
  DeviceDefaultPrefix: string;
  StopCameraText: string;
  OpenButtonText: string;
}
<!-- app.component.html -->
<qr-scanner 
    (capturedQr)="capturedQr($event)"
    [texts]="{
        NotSupportedHTML: `You are using an <strong>outdated</strong> browser.`,
        DeviceDefaultPrefix: `Camera`,
        StopCameraText: `Stop Camera`,
        OpenButtonText: `Open QR Code File...` }">
</qr-scanner>

Styling

Button styles can be changed:

<!-- app.component.html -->
<qr-scanner 
    (capturedQr)="capturedQr($event)"
    [buttonClass]="'ngClassForButtons'">
</qr-scanner>

Upload QR Feature

You can let users upload a QR code using:

<!-- app.component.html -->
<qr-scanner 
    (capturedQr)="capturedQr($event)"
    [allowUpload]="true">
</qr-scanner>

If you only need upload QR feature, you can use the following:

<!-- app.component.html -->
<qr-scanner 
    (capturedQr)="capturedQr($event)"
    [allowUpload]="true"
    [disableScan]="true">
</qr-scanner>

Error handling

Errors are shown on the error output:

<!-- app.component.html -->
<qr-scanner 
    (error)="onError($event)"
    (capturedQr)="capturedQr($event)">
</qr-scanner>
1.1.13

4 years ago

1.1.12

4 years ago

1.1.11

4 years ago

1.1.9

4 years ago

1.1.10

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.1

4 years ago

1.1.2

4 years ago

1.1.0

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago