Skip to content

Commit a47215a

Browse files
committed
add more samples to rtu
1 parent d011127 commit a47215a

201 files changed

Lines changed: 5450 additions & 310 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

barcode-scanner-api-samples/scan-single-barcode/angular/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ npm install
1919
### 2. Run the App
2020

2121
```bash
22-
ng serve
22+
npm run start
2323
```
2424

2525
Then open your browser at http://localhost:4200 to view the sample app.

barcode-scanner-api-samples/scan-single-barcode/angular/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"ng": "ng",
66
"start": "ng serve",
77
"build": "ng build",
8-
"watch": "ng build --watch --configuration development",
9-
"test": "ng test"
8+
"watch": "ng build --watch --configuration development"
109
},
1110
"private": true,
1211
"dependencies": {
Binary file not shown.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<div class="barcode-scanner-hello-world-page">
22
<div class="barcode-scanner-title">
33
<h2 class="barcode-scanner-title-text">Hello World for Angular</h2>
4-
<svg t="1744959268852" class="barcode-scanner-title-logo" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3482"><path d="M435.8 536.2H512V353z" fill="#DD0031" p-id="3483"></path><path d="M400.9 616.8l-52.4 130.8h-97.2L512 163V64L94.9 212.7l63.6 551.5L512 960V616.8z" fill="#DD0031" p-id="3484"></path><path d="M512 353v183.2h76.2z" fill="#C3002F" p-id="3485"></path><path d="M512 64v99l259.8 584.6h-97.2l-52.4-130.8H512V960l353.5-195.8 63.6-551.5z" fill="#C3002F" p-id="3486"></path></svg>
54
</div>
65
<!-- This div will host the barcode scanner's camera view -->
7-
<div class="barcode-scanner-view" #scannerView></div>
6+
<div class="barcode-scanner-view" #barcodeScannerViewRef></div>
87
</div>

barcode-scanner-api-samples/scan-single-barcode/angular/src/app/app.component.spec.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

barcode-scanner-api-samples/scan-single-barcode/angular/src/app/app.component.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,21 @@ import { BarcodeScanner, BarcodeScannerConfig } from 'dynamsoft-barcode-reader-b
99

1010
export class AppComponent {
1111
title = 'angular';
12+
barcodeScanner: BarcodeScanner | null = null;
1213

13-
@ViewChild('scannerView') scannerView!: ElementRef<HTMLDivElement>;
14+
@ViewChild('barcodeScannerViewRef') barcodeScannerViewRef!: ElementRef<HTMLDivElement>;
1415

1516
async ngAfterViewInit(): Promise<void> {
1617
// Configuration object for initializing the BarcodeScanner instance
1718
const config: BarcodeScannerConfig = {
1819
license: "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9", // Replace with your Dynamsoft license key
19-
container: this.scannerView.nativeElement, // Specify where to render the scanner UI
20+
21+
// Specify where to render the scanner UI
22+
// If container is not specified, the UI will take up the full screen
23+
container: this.barcodeScannerViewRef.nativeElement,
2024

2125
// Specify the path for the definition file "barcode-scanner.ui.xml" for the scanner view.
22-
uiPath: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.0.6000/dist/",
26+
uiPath: "https://cdn.jsdelivr.net/npm/dynamsoft-barcode-reader-bundle@11.0.6000/dist/ui/barcode-scanner.ui.xml",
2327

2428
// showUploadImageButton: true,
2529
// scannerViewConfig: {
@@ -34,13 +38,16 @@ export class AppComponent {
3438
}
3539

3640
// Create an instance of the BarcodeScanner with the provided configuration
37-
const barcodeScanner = new BarcodeScanner(config);
41+
this.barcodeScanner = new BarcodeScanner(config);
3842

3943
// Launch the scanner; once a barcode is detected, display its text in an alert
40-
barcodeScanner.launch().then((result) => {
41-
if (result.barcodeResults.length) {
42-
alert(result.barcodeResults[0].text);
43-
}
44-
});
44+
let result = await this.barcodeScanner.launch();
45+
if (result.barcodeResults.length) {
46+
alert(result.barcodeResults[0].text);
47+
}
48+
}
49+
async ngOnDestroy(): Promise<void> {
50+
// Dispose of the barcode scanner when the component unmounts
51+
this.barcodeScanner?.dispose();
4552
}
4653
}

barcode-scanner-api-samples/scan-single-barcode/angular/src/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<title>Dynamsoft Barcode Reader Sample - Hello World (Decode via Camera)</title>
66
<base href="/">
77
<meta name="viewport" content="width=device-width, initial-scale=1">
8-
<link rel="icon" type="image/x-icon" href="favicon.ico">
98
</head>
109
<body>
1110
<app-root></app-root>

0 commit comments

Comments
 (0)