ng2-ui / auto-complete

Angular Auto Complete component and directive
https://ng2-ui.github.io/dist/#/auto-complete
MIT License
279 stars 122 forks source link

Reference error with ssr #367

Open marcvincenti opened 5 years ago

marcvincenti commented 5 years ago

When using auto-complete with ssr, the initialization of the service throw ERROR ReferenceError: document is not defined at NguiAutoCompleteDirective.ngOnInit

Steps to reproduce and a minimal demo

I canno't create a plunker since it's a ssr rendering problem. But to reproduce the problem, you can just test to use the autocomplete module with universal. Then directly from the server the component which use the autocomplete directive.

Current behavior

No rendering, only : ERROR ReferenceError: document is not defined at NguiAutoCompleteDirective.ngOnInit

Expected/desired behavior

No errors being throwed by not initializing the service server side.

Other information

I've opened the pull request #366, where i just check if we are on the browser before running anything in the service.