1- import { Component , ElementRef , ViewChild } from '@angular/core' ;
1+ import { Component , ElementRef , ViewChild , NgZone } from '@angular/core' ;
22import '../dynamsoft.config' ;
33import { CameraEnhancer , CameraView } from 'dynamsoft-barcode-reader-bundle' ;
44import { CaptureVisionRouter } from 'dynamsoft-barcode-reader-bundle' ;
@@ -13,6 +13,8 @@ const componentDestroyedErrorMsg = 'VideoCapture Component Destroyed';
1313 standalone : true ,
1414} )
1515export 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