ngx-scanner
ngx-scanner copied to clipboard
Not working with server side rendering
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