material2-carousel icon indicating copy to clipboard operation
material2-carousel copied to clipboard

It doesn't work with SSR

Open monti-cistella opened this issue 4 years ago • 2 comments

If you import this module and compile with Angular Universal Server Side Rendering, then the project does not work, the website does not charge in the browser.

monti-cistella avatar Jan 28 '21 19:01 monti-cistella

SOLVED!

The problem comes from the startTimer function of the carousel.component.ts. The timer blocks the Server App. It seems that the filter(() => this.isVisible() in the pipe is not enough. I just added a condition if isPlatformBrowser before this times and now it works perfectly:

if (isPlatformBrowser(this.platformId)) { this.timer$ .pipe( takeUntil(this.timerStop$), takeUntil(this.destroy$), filter(() => this.isVisible()) ) .subscribe(() => { this.listKeyManager.withWrap(true).setNextItemActive(); this.listKeyManager.withWrap(this.loop); }); }

If you have the same problem, just apply this solution. In my case I'm using Angular 10.2.3 and Universal 10.1.

monti-cistella avatar Jan 29 '21 12:01 monti-cistella

We are also having the same problem

sagrawal31 avatar Sep 18 '21 12:09 sagrawal31