Closed AbraamNader closed 3 years ago
I get the same error. Angular: 10.1.0 "ngx-device-detector": "^2.0.1" I created the universal-device-detector.service and provided it in app.server.module the same as docs but I'm using that service in my component.
Facing the same issue. Any solution or workaround for this?
@AbraamNader , @Parsa-Sedigh Closed by https://github.com/KoderLabs/ngx-device-detector/pull/183
Thanks to @pritamgb for the PR. New version 2.0.2 released with the fix
Thanks - @AhsanAyaz , @pritamgb
On my side, there is a new error : ERROR TypeError: window.matchMedia is not a function
(before, it was window is not defined
)
I think the fix to test the window object should be the same than you used in the code :
if (isPlatformBrowser(this.platformId) && typeof window !== 'undefined')
Unfortunately, I don't know how to the PR stuff by myself and so on :-)
In the meantime, will downgrade to 2.0.0 :)
Thanks you guys.
Angular Universal Error:
window is not defined
at device-detector.service.tsLine number: 113
Can you please add an undefined check before accessing the window object (e.g.
typeof window !== 'undefined'
)? if it is, set a default value for orientation.Note: this error occurs on the server despite using ngx device detector on the browser only.
Thank you for this awesome library.