Skip to content

Commit 5f2bf81

Browse files
committed
Update video-capture.component.ts
1 parent b85a0ef commit 5f2bf81

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

foundational-api-samples/hello-world/angular/src/app/video-capture/video-capture.component.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ElementRef, ViewChild } from '@angular/core';
1+
import { Component, ElementRef, ViewChild, NgZone } from '@angular/core';
22
import '../dynamsoft.config';
33
import { CameraEnhancer, CameraView } from 'dynamsoft-barcode-reader-bundle';
44
import { CaptureVisionRouter } from 'dynamsoft-barcode-reader-bundle';
@@ -13,6 +13,8 @@ const componentDestroyedErrorMsg = 'VideoCapture Component Destroyed';
1313
standalone: true,
1414
})
1515
export class VideoCaptureComponent {
16+
constructor(private ngZone: NgZone) { }
17+
1618
@ViewChild('cameraViewContainer') cameraViewContainer?: ElementRef<HTMLDivElement>;
1719
resultText = "";
1820

@@ -51,12 +53,13 @@ export class VideoCaptureComponent {
5153
this.cvRouter.addResultReceiver({
5254
onDecodedBarcodesReceived: (result) => {
5355
if (!result.barcodeResultItems.length) return;
54-
55-
this.resultText = '';
5656
console.log(result);
57-
for (let item of result.barcodeResultItems) {
58-
this.resultText += `${item.formatString}: ${item.text}\n\n`;
59-
}
57+
this.ngZone.run(() => {
58+
this.resultText = '';
59+
for (let item of result.barcodeResultItems) {
60+
this.resultText += `${item.formatString}: ${item.text}\n\n`;
61+
}
62+
});
6063
},
6164
});
6265

@@ -103,6 +106,6 @@ export class VideoCaptureComponent {
103106
await this.pInit;
104107
this.cvRouter?.dispose();
105108
this.cameraEnhancer?.dispose();
106-
} catch (_) {}
109+
} catch (_) { }
107110
}
108111
}

0 commit comments

Comments
 (0)