Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Angular 17 SSR, initial load displays slides stacked in a column even when the numbers of items per breakpoint is 1. #280

Open
devKwenda opened this issue Sep 25, 2024 · 2 comments

Comments

@devKwenda
Copy link

image

@devKwenda devKwenda changed the title In Angular 17 SSR, inicial load displays slides stacked in a column even when the numbers of items per breakpoint is 1. In Angular 17 SSR, initial load displays slides stacked in a column even when the numbers of items per breakpoint is 1. Sep 25, 2024
@Syamhere
Copy link

Syamhere commented Oct 9, 2024

Fix the carousel rendering issue in Angular 17 SSR by adding a platform check

Added a condition to wrap the carousel in an *ngIf="isBrowser" directive to ensure it only renders on the client side. This prevents the carousel from stacking items on the initial load due to server-side rendering (SSR) rendering the same content, ensuring proper display in the browser.

constructor(@Inject(PLATFORM_ID) private platformId: Object) {}

ngOnInit() {
  this.isBrowser = isPlatformBrowser(this.platformId);
}

@CedBadarou
Copy link

Fix the carousel rendering issue in Angular 17 SSR by adding a platform check

Added a condition to wrap the carousel in an *ngIf="isBrowser" directive to ensure it only renders on the client side. This prevents the carousel from stacking items on the initial load due to server-side rendering (SSR) rendering the same content, ensuring proper display in the browser.

constructor(@Inject(PLATFORM_ID) private platformId: Object) {}

ngOnInit() {
  this.isBrowser = isPlatformBrowser(this.platformId);
}

This means that the carousel won't be in the HTML sent by the server ? Isn't it a problem, SEO wise ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants