question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compatibility with Angular Universal

See original GitHub issue

Hello,

I’m trying to integrate the component into my app, using Universal server-side rendering.

My code works fine (thanks for this good component!) without the SSR.

When running with SSR, this error occurs :

ERROR TypeError: this.elemRef.nativeElement.getBoundingClientRect is not a function
    at MinHDirective.JqLiteWrapper.getBoundingClientRect (path_to_project\node_modules\ng5-slider\bundles\ng5-slider.umd.js:201:43)

So it seems that the component doesn’t deal with SSR constraints (no access to browser window, etc…).

Should it be possible to make this component working with Universal ? In the meantime, did someone find a workaround ?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

30reactions
harellevycommented, Mar 7, 2019

just put in the constructor like this:

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

and

*ngIf="isBrowser"

in the element that wraps ng5-slider component

3reactions
piotrdzcommented, Feb 3, 2019

No, I’m afraid the slider component is currently very closely tied to the browser. getBoundingClientRect() is necessary to calculate slider bounds and position the sub-elements accordingly.

To support something like Angular Universal, the slider layout would need to be re-written to use pure CSS in some clever way. I would have to research this further to see if this is possible. It would be actually a good thing to do, because it would also solve current performance issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server-side rendering (SSR) with Angular Universal
This guide describes Angular Universal, a technology that renders Angular applications on the server. A normal Angular application executes in the browser, ...
Read more >
Angular Universal: Complete Practical Guide
This post will be a complete practical guide for getting started with Angular Universal. We are going to go start with an existing...
Read more >
Angular Universal: real app problems - InDepth.Dev
In fact, Angular Universal is the only supported and most widely used solution for rendering Angular applications on the server. The difficulty of...
Read more >
Releases · angular/universal - GitHub
Angular universal no longer supports Node.js versions 14.[15-19].x and 16.[10-12].x . Current supported versions of Node.js are 14.20.x ...
Read more >
Server Side rendering with Angular universal 14 - Ganatan
Angular -universal allows to manage the seo with the server side rendering technique.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found