ngx-scanner icon indicating copy to clipboard operation
ngx-scanner copied to clipboard

Not working with server side rendering

Open perotom opened this issue 3 years ago • 0 comments

Describe the bug When used with a SSR Angular project, node main.js will fail with ReferenceError: window is not defined. My HTML looks like:

<zxing-scanner *ngIf="isBrowser" #qrscanner
                 (scanSuccess)="scanSuccessHandler($event)"
                 (camerasFound)="onCamerasFound($event)"></zxing-scanner>

And my typescript:

@ViewChild('qrscanner', { static: true })
private qrScanner: ZXingScannerComponent;

constructor(@Inject(PLATFORM_ID) private platformId) {
    this.isBrowser = isPlatformBrowser(platformId);
}

Seems similar to: https://github.com/werthdavid/ngx-kjua/pull/3/files

perotom avatar Jan 09 '22 16:01 perotom